Neon Number

A neon number is a number where the sum of digits of the square of the number is equal to the number. Let’s take an example. n = 9. square = 81. sum of digits of square = 8 + 1 = 9.

Program:-

package payilagam.institution;

public class Neon {

	public static void main(String[] args) {
       int num = 9;
       int num2=num*num;
       int total = 0,temp=0;
       while(num2>0)
       {
    	   
    	   temp = num2%10;    	  
    	   total = total + temp; 
    	   num2= num2/10; 
    	     	}
       System.out.println(total);
       if (num==total)
       {
    	   System.out.println("it is a Neon Number");
       }
       else
       {
    	   System.out.println("it is not a Neon Number");
   
       }
	}
		
}

Output Screenshot:-

Leave a Reply

Create your own website, free on WordPress.com.Create your own website.
Start free