summaryrefslogtreecommitdiff
path: root/Problem14.py
blob: f7a93b3be735988a704cec8bedd9e2894ea18f8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
def sequence(x):
    count = 1
    while x > 1:
        if(x%2 == 0):
            x=x/2
        else:
            x=(x*3)+1
        count+=1
    return count
print(sequence(13))
maxval, maxcount = 0,0
for x in range(1000000,100000,-1):
    currentSequence = sequence(x) 
    if currentSequence > maxcount:
        maxcount = currentSequence
        maxval = x
    print(maxval,"with max sequence count of:",maxcount)