17 lines
378 B
Python
17 lines
378 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
# closed form expression, d = digits
|
||
|
# if d is even: 20 * 30**(d/2 - 1)
|
||
|
# if d = 3+4n : 5 * 20**((d+1)/4) * 25**((i-3)/4)
|
||
|
# iterate all digits in range
|
||
|
|
||
|
def main(d): #inclusive
|
||
|
r = 0
|
||
|
for i in range(2,d+1,2):
|
||
|
r += 20*30**(i//2 - 1)
|
||
|
for i in range(3,d+1,4):
|
||
|
r += 5 * 20**((i+1)//4) * 25**((i-3)//4)
|
||
|
return r
|
||
|
|
||
|
print(main(9))
|