Soluții
Sunny Number in Java
Sunny Number
A number is called a sunny number if the number next to the given number is a perfect square. In other words, a number N will be a sunny number if N+1 is a perfect square.
Let’s understand it through an example.Suppose, we have to check if 80 is a sunny number or not. Given, N=80 then N+1 will be 80+1=81, which is a perfect square of the number 9. Hence 80 is a sunny number.
Let’s take another number 10.
Given, N=10 then N+1 will be 10+1=11, which is not a perfect square. Hence 10 is not a sunny number.
Steps to Find Sunny Number
The logic is very simple. To find the sunny number, we need only to check whether N+1 is the perfect square or not.
- Read or initialize a number (num).
- Add 1 to the given number i.e. num+1.
- Find the square root of num+1.
- If the square root is an integer, the given number is sunny, else not a sunny number.
Peterson Number in Java
[mai mult...]Automorphic Number Program in Java
A number is called an automorphic number if and only if the square of the given number ends with the same number itself. For example, 25, 76 are automorphic numbers because their square is 625 and 5776, respectively and the last two digits of the square represent the number itself. Some other automorphic numbers are 5, 6, 36, 890625, etc.
[mai mult...]Fascinating Number in Java
Multiplying a number by two and three separately, the number obtained by writing the results obtained with the given number will be called a fascinating number. If the result obtained after concatenation contains all digits from 1 to 9, exactly once.
In other words, we can also say that a number (n) may be a fascinating number if it satisfies the following two conditions:
- If the given number is a 3 or more than three-digit
- If the value getting after concatenation contains all digits from 1 to 9, exactly once.
For example, 192, 1920, 2019, 327, etc. Let’s understand the concept of fascinating numbers through an example.
[mai mult...]