Adopted new convention from template

This commit is contained in:
David Doblas Jiménez 2022-09-30 21:08:21 +02:00
parent 1b4f2f2fa6
commit 80bb7a94ed

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python
""" """
Created on 23 Jun 2021 Created on 23 Jun 2021
@ -15,29 +15,30 @@ from utils import timeit
@timeit("Problem 40") @timeit("Problem 40")
def compute(): def compute():
""" """
An irrational decimal fraction is created by concatenating the positive integers: An irrational decimal fraction is created by concatenating the positive
integers:
0.123456789101112131415161718192021... 0.123456789101112131415161718192021...
It can be seen that the 12th digit of the fractional part is 1. It can be seen that the 12th digit of the fractional part is 1.
If d_n represents the n^th digit of the fractional part, find the value of the following expression. If d_n represents the n^th digit of the fractional part, find the value of
the following expression.
d_1 × d_{10} × d_{100} × d_{1_000} × d_{10_000} × d_{100_000} × d_{1_000_000}
d_1 x d_{10} x d_{100} x d_{1_000} x d_{10_000} x d_{100_000}
x d_{1_000_000}
""" """
fraction = '' fraction = ""
for i in range(1, 1_000_000): for i in range(1, 1_000_000):
fraction += str(i) fraction += str(i)
ans = 1 ans = 1
for i in range(7): for i in range(7):
ans*= int(fraction[10**i - 1]) ans *= int(fraction[10**i - 1])
return ans return ans
if __name__ == "__main__": if __name__ == "__main__":
print(f"Result for Problem 40 is {compute()}")
print(f"Result for Problem 40: {compute()}")