@abakcus
@mathladyhazel
Merci, très beau !
Si on fait une itération de plus, c’est joli à droite:
(1234567890 + 10) x 8 + 10 = 9876543210,
mais c’est moins beau à gauche...
1234567900 x 8 + 10 = 9876543210
Dommage !!! Toute belle chose à une fin !
@abakcus
Let b be the base (in this case 10)
n = line number, 1<=k<=n
The pattern is
n + (b-2)*sum_k k*b^(n-k) = sum_k (b-k)*b^(n-k)
Combine both sums
n = sum_k (b-k)*b^(n-k) + (2-b)*k*b^(n-k)
Simplify
n = sum_k (1-k)*b^(n-k+1) + k*b^(n-k)
Telescope the sum
n = n*b^(n-n) - (1-1)*b^(n-1+1)
@abakcus
@GWOMaths
>>> total =0
>>> for i in range(1,10):
... total = total + (i*pow(10,(10-i)))
... z = total/pow(10,(10-i))
... print(8*z+i)
...
9
98
987
9876
98765
987654
9876543
98765432
987654321