Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- k_values = [5,6,7,8,9,10]
- number = """80305819756942201375489585898582728359125376393672671890721258654640153063276854646941512424482871973450275648094326370821684146232021234968910743756427552137119181427345918091192930953879191131615498683155730974186245381895299995291613811708839994166310513251189919219826383686381464772845357534156859312826087485080157185139202555905605217833563998277996607549524048542945963928412993312995837811367747710931675453035653603870077749346653539898270498391583882067683196221572122566860049520394681148043214626713474719896643906244563446783220621099157896055732912725327667265881006760363373158076659578274777675940242792984297001876714737941868642345530486796146981710372091896896539704018815333888513675015212932696404070975645710269418633"""
- answer = [0,0,0,0,0,0]
- for i in range(0,len(k_values)):
- k = k_values[i]
- maximum_product = 0
- for j in range(0,len(number)-k+1):
- product = 1;
- for l in range(j,j+k):
- num = int(number[l])
- product = product * num
- if(product > maximum_product):
- maximum_product = product
- answer[i] = maximum_product
- for i in range(0,len(answer)):
- print("K =",k_values[i],", Answer =",answer[i])
- # OUTPUT:
- # K = 5 , Answer = 32805
- # K = 6 , Answer = 186624
- # K = 7 , Answer = 1036800
- # K = 8 , Answer = 8294400
- # K = 9 , Answer = 41472000
- # K = 10 , Answer = 331776000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement