0

Complete rookie. When I run the below it returns decimals. How do I get this to return whole number?

n = 17

while n != 1:         
    if (n % 2 == 0):  
        n = n/2          
        print(int(n))
    else:             
        n = (3*n)+1
        print(int(n))

Result:

py> python cold.py
52
26.0
13.0
40.0
20.0
10.0
5.0
16.0
8.0
4.0
2.0
1.0
Brett Beatty
  • 5,690
  • 1
  • 23
  • 37

0 Answers0