David Doblas Jiménez 7c8165d9c2 Clean-up
2021-09-20 17:53:15 +02:00

43 lines
926 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
Created on 23 Jun 2021
@author: David Doblas Jiménez
@email: daviddoji@pm.me
Solution for problem 40 of Project Euler
https://projecteuler.net/problem=40
"""
from utils import timeit
@timeit("Problem 40")
def compute():
"""
An irrational decimal fraction is created by concatenating the positive integers:
0.123456789101112131415161718192021...
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.
d_1 × d_{10} × d_{100} × d_{1_000} × d_{10_000} × d_{100_000} × d_{1_000_000}
"""
fraction = ''
for i in range(1, 1_000_000):
fraction += str(i)
ans = 1
for i in range(7):
ans*= int(fraction[10**i - 1])
return ans
if __name__ == "__main__":
print(f"Result for Problem 40: {compute()}")