Back
Close

Armstrong Numbers

Statement

 Goal

Given a positive integer n, find all Armstrong numbers less than n.

A positive integer is an Armstrong number if it is equal to the sum of each digit raised to the power of the number of digits. For example, 153 is an Armstrong number since 153 = 1³ + 5³ + 3³.
Input
Line 1: A positive integer n
Output
All Armstrong numbers less than n, in ascending order, one on each line
Constraints
0 < n < 100000
Example
Input
5
Output
1
2
3
4

Game modes
Fastest, Shortest

Test cases
Test 1 Test
Input
5
Output
1 2 3 4

Validator 1 Validator
Input
9
Output
1 2 3 4 5 6 7 8

Test 2 Test
Input
10
Output
1 2 3 4 5 6 7 8 9

Validator 2 Validator
Input
3
Output
1 2

Test 3 Test
Input
372
Output
1 2 3 4 5 6 7 8 9 153 370 371

Validator 3 Validator
Input
371
Output
1 2 3 4 5 6 7 8 9 153 370

Test 4 Test
Input
2
Output
1

Validator 4 Validator
Input
99999
Output
1 2 3 4 5 6 7 8 9 153 370 371 407 1634 8208 9474 54748 92727 93084

Solution language

Solution

Stub generator input