I think triangular numbers come into play here if we look at the positions of the numbers:
Position: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15, 16 17 18 19 20 21, 22 23 24 25 26 27 28 Number: 1, 1 2, 1 2 3, 1 2 3 4, 1 2 3 4 5, 1 2 3 4 5 6, 1 2 3 4 5 6 7,
Call this sequence N (p).
Now look at the triangular numbers that have the formula k (k + 1) / 2
k : 1 2 3 4 5 6 k(k+1)/2 : 1 3 6 10 15 21 triangle numbers k(k+1)/2+1 : 2 4 7 11 16 22 plus one N(k(k+1)/2+1): 1 1 1 1 1 1 item at this position
therefore, the element immediately after the nth triangular number is always equal to 1.
Give the position p , we will find the nearest k , so k (k + 1) / 2 +1 <= p. We can solve the quadratic x (x + 1) / 2 + 1 = p by rearranging
0.5 x^2 + 0.5 x + 1 - p = 0.
So, a = 0.5, b = 0.5 and c = 1-p. The solution for x gives
x = -0.5 +/- sqrt( 0.25 - 2 * (1-p) )
take the positive sign that gives these values
1 0 2 1 3 1.5615528128 4 2 5 2.3722813233 6 2.7015621187 7 3 8 3.2749172176 9 3.5311288741 10 3.7720018727 11 4 12 4.216990566 13 4.4244289009 14 4.623475383 15 4.8150729064 16 5
So, if we take k = gender (-0.5 +/- sqrt (2 p - 1.75)), we find the number k. Then find l = pk (k + 1) / 2, which gives the digit in the pth place.
As indicated, this fails as soon as we get two-digit numbers. But we could make an adjustment. We can get the formula "triangular digit-number" TD (k). Which behaves like triangular numbers, T (k), for k <10, but adds extra digits.
k : 1 ... 9 10 11 12 T(k) : 1 45 55 66 78 change 1 3 6 TD(k) : 2 45 56 69 84
We see that for 10 <= k <99 you just need to add T (k) + T (k-9). This should give us another quadratic problem that we could solve. It happens similarly for 100 <= k <= 999 with T (k) + T (k-9) + T (k-99).
Now T(k)+T(k-9) + 1 = k(k+1)/2 +(k-9)(k-8)/2 + 1 = 0.5 k^2 + 0.5 k + 0.5 k^2 - 17/2 k + 72/2 + 1 = k^2 -8 k + 37
Solve x ^ 2 -8 k + 37 - p = 0 gives
x = ( 8 +/- sqrt(64 - 4 *(37-p) ) ) /2 = ( 8 +/- sqrt(4 p - 64) )/2 = 4 +/- sqrt(p - 21)
taking the word gives us the value of k.
We want to find the sum of the triangles T (k) + T (k-9) + T (k-99) + .... In a first approximation, T (kn) = T (n) for any n. So the sum is just d * T(k) where d is in the number of digits k. T (k) is approximately k ^ 2/2, so the sum is approximately d * k^2/2 2/2. This is easy to solve, let d be the number of digits of position p, then k = sqrt(2*p/d) . You can use this to get an approximate guess for k.