9*(2^n) from the pattern of the first several terms.
notes: The number digits in the terms to be multiplied goes from 1,2,4,8,16, ...
The terms begin at n = 0
The first several terms work out to:
0 9 9 9
1 99 891 18
2 9999 8909109 36
3 99999999 890910891090891 72
4 9999999999999999 8909108910908909109089108909109 144
5 99999999999999999999999999999999 890910891090890910908910890910891090891089091090890910891090891 288
-----
def sod(n):
""" Input an integer. Returns the Sum of the Digits """
aList = list(str(n))
ans = 0
for c in aList:
ans = ans + int(c)
return ans
def f(n):
return 10**(2**n) - 1
def g(n):
prod = 1
for i in range(n+1):
prod *= f(i)
return prod
for i in range(6):
print(i,f(i), g(i), sod(g(i)))
|
Posted by Larry
on 2024-01-04 11:57:44 |