aboutsummaryrefslogtreecommitdiffstats
path: root/ee2301/collatz.py
blob: acbc12edaeca5a5944f04eaf550e37e25b02bc6e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
def collatzCount(number):
    for n in range (1,number+1):
        collatzConjecture(n)
        print("\n")

def collatzConjecture(n):
    print(n, end = ' ')
    if n is 1:
        return 1
    else:
        if n%2:
            return collatzConjecture(int((n*3)+1))
        else:
            return collatzConjecture(int(n/2))
        raise AssertionError

#main
for i in range (1,2):
    print("")

collatzCount(100)