Neon Number.

Program to check whether a given number is Neon or not.


A neon number is a number where the sum of digits of square of the number is equal to the number. For example if the input number is 9, its square is 9*9=81 and sum of the digits is 9 i.e, 9 is a neon number.







SOURCE CODE


import java.io.*;
public class Neon
{
    public static void main(String args[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter a Number  :");
        int a=Integer.parseInt(br.readLine());
        int sq=a*a;
        int rem,num=0,n;
        n=sq;
        while(n>0)
        {
            rem=n%10;
            num=num+rem;
            n=n/10;
        }
        if(num==a)
        System.out.println("Yes,It is a Neon number");
        else
        System.out.println("No,It is not a Neon number");
    }
}


Click here to Download


OUTPUT





If you have any question then leave a comment below I will do my best to answer that question.

Comments

Popular posts from this blog

[Question 3] ISC 2017 Computer Practical Paper Solved – Caesar Cipher.

Pattern of your own name.

Designing Patterns - Print 'Z'.