Program To Print Neon Number JAVA


Write a Program to print whether the inputted 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 , sum of its digits = 1 + 8 = 9]


import java.util.*;
class neon
{
    public static void main(String args[])
    {
     Scanner sc = new Scanner (System.in);
     int n = sc.nextInt();
     int sq = n * n,sum =0;
     while (sq!=0)
     {
         sum = sum + (sq%10);
         sq=sq/10;
     }
     
     if(sum == n)
     {
     System.out.println("yes it is neon number");
     }
     else
     {
     System.out.println("No it is not neon");
    }
 }
}

     
                     

Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com