Neon Number in Java

How Can We Help?

Table of Contents

What is Neon Number?

A Neon number is a number where the sum of digits of square of the number is equal to the number. For instance, the square is 9*9 = 81, and the sum of the digits of the square is 9.

Compile and Run the following code with Command-Prompt Or download Notepad++

For Compilation javac

For Execution java Sample

import java.util.Scanner;
class Sample
  public static void main(String args[])
    int n,square,sum = 0;
    Scanner sc = new Scanner(;
    System.out.println("Enter the number of your choice: ");
    n = sc.nextInt();
    square = n*n;
      sum =sum + square % 10;
      square = square/10;
    if(sum == n)
      System.out.println("The number is Neon Number");
      System.out.println("The number is not Neon Number");

Leave a Reply