Search

# Collatz Conjecture in Python - Python Programming Essentials | AskTheCode

Based on question asked in Python Programming Essentials course on Coursera | Week 3 solution code | Simple python program on Collatz Conjecture | Python

def f(n):

return n // 2 if n % 2 == 0 else 3*n + 1

print (f(f(f(f(f(f(f(f(f(f(f(f(f(f(1071)))))))))))))))

19 views

### Recent Posts

See All

#### Binary string reduction in Python

Asked: Sudeep |Category: Python x=int(input("Enter the value of x : ")) for i in range(x): n=int(input("Enter the value of n : ")) y=input("Enter the value of y : ") l=list(y) k=0

#### Finding sum of digits of a number until sum becomes single digit

Asked: Pushkar Tiwari |Category: Python n=eval(input("Enter the value of n : ")) import math def digSum( n): sum = 0 while(n > 0 or sum > 9): if(n == 0): n = sum

#### Lists | HACKER RANK

Asked: Rahul Kumar Ranjan |Category: Python n=int(input()) l=[] for i in range (n): x=input().split(" ") com=x if com=="insert": l.insert(int(x),int(x)) elif com=="print": print(l) elif com==