C++ Program To Check And Print Neon Number in a Given Range Last Updated : 22 Feb, 2023 Comments Improve Suggest changes Like Article Like Report A neon number is a number where the sum of digits of the square of the number is equal to the number. The task is to check and print neon numbers in a range. Examples: Input: 9 Output: Neon Number Explanation: square is 9*9 = 81 and sum of the digits of the square is 9. Input: 12 Output: Not a Neon Number Explanation: square is 12*12 = 144 and sum of the digits of the square is 9 (1 + 4 + 4) which is not equal to 12. The implementation is simple, we first compute square of given number, the find sum of digits in the square. C++ // C++ program to check and print // Neon Numbers upto 10000 #include <iostream> using namespace std; #include <math.h> int checkNeon(int x) { // Storing the square of x int sq = x * x; // Calculating the sum of // digits of sq int sum_digits = 0; while (sq != 0) { sum_digits = sum_digits + sq % 10; sq = sq / 10; } return (sum_digits == x); } // Driver Code int main(void) { // Printing Neon Numbers upto 10000 for (int i = 1; i <= 10000; i++) if (checkNeon(i)) cout << i << " "; } Output: 1 9 Time Complexity: O(n*log10(n*n)) where n is the number till which neon numbers to be printed. Space Complexity: O(1) as no extra space has been used. Comment More infoAdvertise with us Next Article C++ Program To Check And Print Neon Number in a Given Range K kartik Follow Improve Article Tags : C++ Programs C++ C Basic Programs Practice Tags : CPP Similar Reads C Program To Find Prime Numbers Between Given Range A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. For example, 2, 3, 5, 7, and 11 are prime numbers. In this article, we will learn how to find all the prime numbers between the given range.ExampleInput: l = 10, r = 30Output: 11 13 17 19Explanat 6 min read C++ Program To Find Prime Numbers Between Given Interval A prime number is defined as a natural number greater than 1 and is divisible by only 1 and itself. In other words, the prime number is a positive integer greater than 1 that has exactly two factors, 1 and the number itself. The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23 . . .Note: 1 7 min read C++ Program to Print Armstrong Numbers Between 1 to 1000 Here, we will see how to print Armstrong numbers between 1 to 1000 using a C++ program. Armstrong Number A number "N" is an Armstrong number if "N" is equal to the sum of all N's digits raised to the power of the number of digits in N. Example: There are 2 ways to find all the Armstrong numbers betw 3 min read C++ Program to Print Prime Numbers from 1 to n A prime number is a natural number that has only two divisors, which are 1 and itself. In this article, we will learn how to print all the prime numbers from 1 to n in C++.ExamplesInput: n = 10Output: 2, 3, 5, 7Explanation: As 2, 3, 5, 7 are the only prime numbers between 1 to 10.Input: n = 5Output: 5 min read How to Find the Range of Numbers in an Array in C++? The range of numbers in an array means the difference between the maximum value and the minimum value in the given array. In this article, we will learn how to find the range of numbers in an array in C++. For Example, Input: myArray = {5,10,15,30,25}; Output: Range: 25Range Within an Array in C++To 2 min read Like