-
Notifications
You must be signed in to change notification settings - Fork 1
/
008.py
21 lines (15 loc) · 1.26 KB
/
008.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Largest product in a series
# Problem 8
import functools
n = '73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557'
n += '66896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776'
n += '65727333001053367881220235421809751254540594752243525849077116705560136048395864467063244157221553975369781797784617406495514929086256932197846862248283972241375657056057490261407972968652414535100474'
n += '82166370484403199890008895243450658541227588666881164271714799244429282308634656748139191231628245861786645835912456652947654568284891288314260769004224219022671055626321111109370544217506941658960408'
n += '07198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450'
digits = list(map(int, str(n)))
result = 0
for i in range(987):
prod = functools.reduce(lambda a, b: a * b, digits[i:i+13])
if prod > result:
result = prod
print(result)