We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #14: Longest Collatz sequence
Project Euler #14: Longest Collatz sequence
Contest ends in
Sort by
recency
|
203 Discussions
|
Please Login in order to post a comment
Can anyone help reduce runtime of this code
is doing like this is fine?
My solution in C:
c code
int main() {
}
def collats(n): if n==1: return(1) if n%2==1: return(1+collats(3*n+1)) else: return(1+collats(n/2)) for i in range(int(input())): print(collats(int(input())))