Santa and the elves are doing the last of the preparations getting ready to set off into the sky tonigh. As they get ready the ordering of the elves going through the halls is important to keep order and so nothing gets mixed up.
Elves use a system of numbering creatively called Elf Numbers. There is a formula mapping regular natural numbers to elf numbers. For each digit of a natural number put it through the following formula and add up all the results for each digit. Then repeat that process over and over again. If the sum is ever equal to 0 then the number is an Elf number. If the sum never reaches 0 then it is not an Elf Number.
The formula is:
Here’s the first 10 numbers put through the formula once.
0 | 0 |
1 | 8 |
2 | 0 |
3 | 0 |
4 | 32 |
5 | 120 |
6 | 288 |
7 | 560 |
8 | 960 |
9 | 1512 |
Taking 4 as an example through the full process:
Taking 8 as an example through the full process:
Therefore 4 is an Elf Number and 8 will never terminate so it is not an Elf Number.
Problem: It’s imperative that Santa knows the sum of the first 50,000 Elf Numbers. Report back to Santa as soon as you get the results.