DEV Community

hema latha
hema latha

Posted on

Neon number

A positive integer whose sum of digits of its square is equal to the number itself is called a neon number.

Image description

0-100000 Neon numbers = 0,1,9

package day1;

public class Neon_number {

public static void main(String[] args) {
    // TODO Auto-generated method stub
Enter fullscreen mode Exit fullscreen mode

int no = 9;
int square = no*no;
System.out.println(square);
int result = sum_of_digits(square);
System.out.println(result);
if (result==no)
System.out.println("neon");
else
System.out.println("Not Neon");

}

private static int sum_of_digits(int square) {
    // TODO Auto-generated method stub

    int sum = 0;
    while(square>0)
    {
        sum = sum+square%10;
        square = square/10;
    }
    return sum;



}
Enter fullscreen mode Exit fullscreen mode

}

out put=
81
9
neon

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more