![]() |
VOOZH | about |
Armstrong numbers are those numbers in which the sum of digits raised to the power of a number of digits in that number will be equal to the number itself. Here will see how to build a C Program to Display Armstrong numbers between 1 to 1000.
Example:
153 13 + 53 + 33 1 + 125 + 27 = 153
All Armstrong number between 1 and 1000 are: 1 2 3 4 5 6 7 8 9 153 370 371 407
Time Complexity: O(n * k) where n is the range of numbers to be checked (1 to 1000 in this case) and k is the maximum number of digits in any number in the range (3 in this case). This is because the loop runs for each number in the range and for each number, we calculate the sum of its digits raised to the power of k.
Space Complexity: O(1) as we are only using a constant amount of extra space for variables to store the count, sum, and current number being checked.
All one-digit numbers are Armstrong numbers.
All Armstrong number between 1 and 1000 are: 1 2 3 4 5 6 7 8 9 153 370 371 407