(Related)
Given an integer n > 1
,
1) Construct the range of numbers n, n-1, n-2, ... 3, 2, 1
and calculate the sum
2) Take the individual digits of that number and calculate the product
3) Take the individual digits of that number and calculate the sum
4) Repeat steps 2 and 3 until you reach a single digit. That digit is the result.
The first twenty terms of the sequence are below:
3, 6, 0, 5, 2, 7, 9, 2, 7, 9, 1, 9, 0, 0, 9, 6, 7, 0, 0, 6
Note: This sequence is NOT in OEIS.
I/O and Rules
- Numbers will get very large quickly, so the solution must be able to handle input numbers up to 100,000 without failure (it's fine if your code can handle past that).
- The input and output can be given by any convenient method.
- Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
- Standard loopholes are forbidden.
- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.
Examples
n output
1234 9
3005 3
5007 5
9854 8
75849 8
100000 0
n
. The solution posted only has to work up ton = 100000
. \$\endgroup\$Numbers will get very large quickly
no it doesn't \$\endgroup\$