Suppose the number S consists of M digits. For example, if S = 370, then M (the number of digits) = 3
Implement the getNumbers method. Among natural numbers less than N (long), it should
find all the numbers satisfying the following criterion:
The number S is equal to the sum of its digits raised in the Mth

# Number algorithms

- 20
Locked

Comments (6)

- Popular
- New
- Old

You must be signed in to leave a comment

jjopc

20 November 2021, 18:59

I don't see the point of this extremely difficult task at this point in the course. I could only get over it by searching in google and reading the help section.

+1

Gellert Varga

28 December 2021, 00:07

I feel the same way.
But here is a very unique idea:
There are only 89 Armstrong numbers in the decimal number system. All 89 are listed here:
https://hu.wikipedia.org/wiki/Armstrong-szám
or here:
https://mathworld.wolfram.com/NarcissisticNumber.html
- Put all of them in a long[] array (that are less than Long.MAX_VALUE).
- Use this array to return the results.
- Exception: CG does not accept zero as an Armstrong number. So take zero out of the long[] array mentioned above.
(I wish I could come up with such great ideas... but this solution was not my idea, it is from another user. And the validator accepts it. By the way, I have no idea how to make an algorithm that is able to check 9223372036854775807 numbers in less than 10 seconds.)

+2

Bart De Lepeleer

17 December 2020, 17:22

Use Google, or work a lot 😀

0

Anthony Mack

15 December 2020, 16:02

If I run my solution w/o verification it returns the arrays from the Solution input w/o a problem. However, whenever I run the validation, it states that it looks like I have an infinite loop. What gives?

0

Roman

18 December 2020, 07:13

Please post your question with the attached solution in the section Help.

0

Oleksii Chernysh

6 December 2019, 21:22

Interesting task and no pain from validator compared to some previous tasks. Good to know that numbers start from 1, not 0. Possibly this is obvious but I didn't realize this from the requirements. And understood that these are Armstrong numbers only after solving the problem.

0