n = map(int, raw_input().split()) #To read the number of digits and #k consecutive numbers num = int(raw_input()) # To read the digit #print n[1] #print num stri = str(num) product = 0 for i in xrange(len(stri) - n[1] + 1): temp = 1 k = i for j in range(n[1]): temp = temp * int(stri[k]) k = k + 1 if(temp > product): product = temp #print product print product
Showing posts with label Largest Product. Show all posts
Showing posts with label Largest Product. Show all posts
Sunday, September 25, 2016
Project Euler #8 - Largest Product in a series - Python
Subscribe to:
Posts (Atom)