From e71e5db8bf49cce950fe2c22fd7e2c125a25d00d Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Tue, 18 Feb 2020 10:07:23 -0600 Subject: Fix Collatz problem --- OLD/ee2301/collatz.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'OLD/ee2301') diff --git a/OLD/ee2301/collatz.py b/OLD/ee2301/collatz.py index 14873be..5f50ccc 100644 --- a/OLD/ee2301/collatz.py +++ b/OLD/ee2301/collatz.py @@ -1,21 +1,21 @@ -def collatzCount(number): - for n in range (1,number+1): +def collatzCount(k): + for n in range (1,k+1): collatzConjecture(n) - #print("\n") + print("\n") def collatzConjecture(n): - #print(n, end = ' ') + print(n, end = ' ') if n is 1: return 1 - else: + elif n > 1: if n%2: return collatzConjecture(int((n*3)+1)) else: return collatzConjecture(int(n/2)) - raise AssertionError + raise AssertionError try: - collatzCount(10000) + collatzCount(100000) except AssertionError: print("The Collatz Conjecture is false!") -- cgit v1.2.3