@@ -0,0 +1,932 @@
+def collatz_sequence(n):%0A    %22%22%22%0A    Collatz conjecture: start with any positive integer n.Next termis obtained from the previous term as follows: %0A    if the previous term is even, the next term is one half the previous term. %0A    If the previous term is odd, the next term is 3 times the previous term plus 1. %0A    The conjecture states the sequence will always reach 1 regaardess of starting n.%0A    Example:%0A    %3E%3E%3E collatz_sequence(43)%0A    %5B43, 130, 65, 196, 98, 49, 148, 74, 37, 112, 56, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1%5D%0A    %22%22%22%0A    sequence = %5Bn%5D%0A    while n != 1:%0A        if n %25 2 == 0:# even%0A            n //= 2 %0A        else:%0A            n = 3*n +1%0A        sequence.append(n)%0A    return sequence%0A%0A%0Adef main():%0A    n = 43%0A    sequence = collatz_sequence(n)%0A    print(sequence)%0A    print(%22collatz sequence from %25d took %25d steps.%22%25(n,len(sequence)))%0A%0Aif __name__ == '__main__':%0A    main()%0A

Create collatz_sequence.py (#639)