Neon Number in Java
What is Neon Number?
A Neon number is a number where the sum of digits of square of the number is equal to the number. For instance, the square is 9*9 = 81, and the sum of the digits of the square is 9.
Compile and Run the following code with Command-Prompt Or download Notepad++
For Compilation javac Sample.java
For Execution java Sample
import java.util.Scanner; class Sample { public static void main(String args[]) { int n,square,sum = 0; Scanner sc = new Scanner(System.in); System.out.println("Enter the number of your choice: "); n = sc.nextInt(); square = n*n; while(square>0) { sum =sum + square % 10; square = square/10; } if(sum == n) System.out.println("The number is Neon Number"); else System.out.println("The number is not Neon Number"); } }