Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions java-programs/findNeonNumbers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import java.io.*;
public class NeonNumberExample2
{
//function to check Neon Number
static boolean isNeon(int num)
{
//calculate the square of the given number
int sq = num * num;
//stores the sum of digits
int sumOfdigits = 0;
//executes until the condition becomes false
while (sq != 0)
{
//finds the last digit of the variable sq and adds it to the variable sum
sumOfdigits = sumOfdigits + sq % 10;
//removes the last dogit of the variable sq
sq = sq / 10;
}
//compares the sumOgDigits with num and returns the boolean value accordingly
return (sumOfdigits == num);
}
//driver Code
public static void main(String args[])
{
System.out.print("Neon Numbers between the given range are: ");
// 0 is the lowe limit and 100000 is the upper limit
for (int i = 0; i <= 100000; i++)
//calling the user-defined number
if (isNeon(i))
//prints all the neon numbers between given range
System.out.print(i+" ");
}
}