Skip to content

Commit b8e83fb

Browse files
authored
Merge pull request SAMYAK99#700 from div2301/neon
[ADD] Neon Number
2 parents e0920e1 + 3139345 commit b8e83fb

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

C++/neon.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// C/C++ program to check and print
2+
// Neon Numbers upto 10000
3+
#include <iostream>
4+
using namespace std;
5+
#include <math.h>
6+
7+
int checkNeon(int x)
8+
{
9+
// storing the square of x
10+
int sq = x * x;
11+
12+
// calculating the sum of digits
13+
// of sq
14+
int sum_digits = 0;
15+
while (sq != 0) {
16+
sum_digits = sum_digits + sq % 10;
17+
sq = sq / 10;
18+
}
19+
return (sum_digits == x);
20+
}
21+
22+
// Driver Code
23+
int main(void)
24+
{
25+
// Printing Neon Numbers upto 10000
26+
for (int i = 1; i <= 10000; i++)
27+
if (checkNeon(i))
28+
cout << i << " ";
29+
}

0 commit comments

Comments
 (0)