diff --git "a/Beginner Level \360\237\223\201/Collatz's Hypothesis/Collatz's hypothesis.py" "b/Beginner Level \360\237\223\201/Collatz's Hypothesis/Collatz's hypothesis.py" new file mode 100644 index 00000000..b3b0b3d6 --- /dev/null +++ "b/Beginner Level \360\237\223\201/Collatz's Hypothesis/Collatz's hypothesis.py" @@ -0,0 +1,11 @@ +c0 = int(input("Enter an integer and non-zero number: ")) +steps = 0 +while c0 != 1: + if c0%2 ==0: + c0 = c0/2 + steps += 1 + elif c0%2 !=0: + c0= (3*c0) + 1 + steps += 1 + print(int(c0)) +print("steps =", steps) \ No newline at end of file diff --git "a/Beginner Level \360\237\223\201/Collatz's Hypothesis/question.md" "b/Beginner Level \360\237\223\201/Collatz's Hypothesis/question.md" index 8b137891..6efa66ae 100644 --- "a/Beginner Level \360\237\223\201/Collatz's Hypothesis/question.md" +++ "b/Beginner Level \360\237\223\201/Collatz's Hypothesis/question.md" @@ -1 +1 @@ - +Enter an integer to test Collatz's hypothesis.