A number is said to be a Neon Number if the sum of digits of the square of the number is equal to the number itself. Example- 9 is a Neon Number. 9*9=81 and 8+1=9.Hence it is a Neon Number.
import java.util.*;
class neon_number
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n,t,r,s=0;
System.out.println("Enter the no.");
n=sc.nextInt();
t=n;
n=n*n;
while(n>0)
{
r=n%10;
s=s+r;
n=n/10;
}
if(t==s)
System.out.println("Neon no.");
else
System.out.println("Not Neon no.");
}
}
Output:
Enter the no: 9
Neon no.
import java.util.*;
class neon_number
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n,t,r,s=0;
System.out.println("Enter the no.");
n=sc.nextInt();
t=n;
n=n*n;
while(n>0)
{
r=n%10;
s=s+r;
n=n/10;
}
if(t==s)
System.out.println("Neon no.");
else
System.out.println("Not Neon no.");
}
}
Output:
Enter the no: 9
Neon no.