Created
February 15, 2018 23:59
-
-
Save Sasuke78200/52d4abb4b5bb0a78ad124c7848a41ec7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned int ft_collatz_conjecture(unsigned int base) | |
{ | |
static unsigned int count = 0; | |
if(base != 1) | |
{ | |
count++; | |
if(base & 1) | |
{ | |
return ft_collatz_conjecture(base * 3 + 1); | |
} | |
else | |
{ | |
return ft_collatz_conjecture(base / 2); | |
} | |
} | |
return count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment