Neon Number :
A number whose sum of digits of square of the number is equal to the number is called neon number. For example, number 9 is a neon number as its square is 81 and the sum of the digits is 9. i.e. 9 is a neon number. There are only 3 neon numbers. They are 0, 1, and 9.
Example 1 : 9
9
=> 9 * 9
=> 81
=> 8+1
=> 9 = Number = 9 , Hence 9 is a Neon number.
Example 2 : 1
1
= 1 * 1
= 1 = 1 = Number, Hence 1 is an a Neon number.
Example 3 : 7
7
= 7 * 7
= 49
= 4+9
=13 != 7 , Hence 7 is not a Neon number.
Example 1 : 9
9
=> 9 * 9
=> 81
=> 8+1
=> 9 = Number = 9 , Hence 9 is a Neon number.
=> 8+1
=> 9 = Number = 9 , Hence 9 is a Neon number.
Example 2 : 1
1
= 1 * 1
= 1 = 1 = Number, Hence 1 is an a Neon number.
Example 3 : 7
7
= 7 * 7
= 49
= 4+9
=13 != 7 , Hence 7 is not a Neon number.
= 4+9
=13 != 7 , Hence 7 is not a Neon number.
Algorithm to check whether a given number is a Neon Number or not:
Step 1: Accept a number.
Step 2: Calculate the square of a number and store it in a variable (say square).
Step 3: Find the sum of digits of the square of a number and store it in a variable (say sum).
Step 4: If the sum is equal to the accepted number then display "Neon number" else display "Not Neon Number".
Step 5: Stop
Step 3: Find the sum of digits of the square of a number and store it in a variable (say sum).
Step 4: If the sum is equal to the accepted number then display "Neon number" else display "Not Neon Number".
Step 5: Stop
Sample Input and Output:
Input 1: Enter number here --> 1
Output 1: The given number 1 is a Neon number
Input 2: Enter number here --> 9
Output 2: The given number 9 is a Neon number
Input 3: Enter number here --> 7
Output 3: The given number 7 is not a Neon number
Question: Write a program in java to check whether a given number is a Neon number or not.
The above Algorithm can be implemented in JAVA Programming in several ways. Some of the JAVA Program codes are given below:
0 Comments