-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path040.py
16 lines (13 loc) · 801 Bytes
/
040.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Problem URL: https://projecteuler.net/problem=40
# ---------------------------------------------------------------------------------
# An irrational decimal fraction is created by concatenating the positive integers:
# 0.123456789101112131415161718192021...
# ---------------------------------------------------------------------------------
# If d-n represents the nth digit of the fractional part, find the value of the following product:
# d-1 * d-10 * d-100 * d-1,000 * d-10,000 d-100,000 * d-1,000,000
# concatenate the first million positive integers into a string
fractional_part = ''.join(str(i) for i in range(1, (10**6 + 1)))
product = 1
for i in range(7): # use powers of 10 to access the desired digits
product *= int(fractional_part[10**i - 1])
print(f"Digit product: {product}")