A triangular number is a number that can be expressed as the sum of consecutive positive integers, starting at 1. They can also be expressed with the formula n(n + 1) / 2, where n is some positive integer.
A number's digitangular counterpart is calculated in the following way:
- Split a number into an array of its digits e.g.
613 => [6 1 3] - For each number in the array, calculate the
nth triangular number;[6 1 3] => [21 1 6] - Sum the resultant array;
[21 1 6] => 28
Your task is, given an integer n, repeatedly calculate n's digitangular counterpart, until the result is equal to 1, then output all values that were calculated. You may output the values in any order, and with an optional inclusion of the original number at the start of the array. This is a code-golf so the shortest code wins.
Test cases
23 => 9 45 25 18 37 34 16 22 6 21 4 10 1
72 => 31 7 28 39 51 16 22 6 21 4 10 1
55 => 30 6 21 4 10 1
78 => 64 31 7 28 39 51 16 22 6 21 4 10 1
613 => 28 39 51 16 22 6 21 4 10 1
8392 => 90 45 25 18 37 34 16 22 6 21 4 10 1
11111 => 5 15 16 22 6 21 4 10 1
8592025 => 117 30 6 21 4 10 1
999999999 => 405 25 18 37 34 16 22 6 21 4 10 1
141and hasndigits. The maximum value its digitangular counterpart can have is45n, sodigi-△(x) ≤ 45n < 45(1+log_10(x)), and forx > 141, we have45(1+log_10(x)) < x, hencedigi-△(x) ≤ x-1forx > 141, and once we pass the141limit, well, we brute force prove via programs. – Simply Beautiful Art 16 hours ago