What is Neon number in java

A number is said to be a neon number if sum of the digits of the square of the number is equal to the number itself.

  • For example : 9 is a neon number
  • Sample Input: 9
  • Sample Output: 9 x 9 = 81 and sum of ( 8 + 1 ) = 9
  • 9 is a Neon number
// program to check whether a number is Neon or not

import java.util.Scanner;
class Neon
 {
 public static void main(String args[])
  {
  int num,rem,sum=0,sqr;
  Scanner sc=new Scanner(System.in);
  System.out.println("Enter any number");
  num=sc.nextInt();
  sqr=num*num;
  do
    {
     rem=sqr%10;
     sum=sum+rem;
     sqr=sqr/10;
     }while(sqr!=0);
  if(sum==num)
    System.out.println(num+" is Neon number");
   else
    System.out.println(num+" is not a Neon number");
   }
 }

Output: