Tuesday, June 1, 2021

JAVA Program to check a neon number (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).

PROGRAM :

package com.company;

import java.util.Scanner;

class neon

{

        public static void main(String args[])

        {

                Scanner s=new Scanner(System.in);

                System.out.println(" Enter a number");

                int orinum=s.nextInt();

                int num=orinum*orinum;

                int sum=0;

                while(num!=0)

                {

                        int n1=num%10;

                        sum=sum+n1;

                        num=num/10;

                }

 

                if(orinum==sum)

                        System.out.println(orinum+ " is a neon number");

                else

                        System.out.println(orinum+ " is a not neon number");

        }

}


OUTPUT :



Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home