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

Lists | HACKER RANK

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

"Believe you can and you're halfway there"