-
-
Save parzibyte/1f75ddba885910e8d360a8a19de9ae51 to your computer and use it in GitHub Desktop.
This file contains 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 long long collatz(unsigned long long numero) | |
{ | |
// https://parzibyte.me/blog | |
unsigned long long iteraciones = 0; | |
while (numero != 1) | |
{ | |
if (numero % 2 == 0) | |
{ | |
numero = numero / 2; | |
} | |
else | |
{ | |
numero = (3 * numero) + 1; | |
} | |
// Si no quieres imprimir, simplemente elimina o comenta la siguiente línea | |
printf("%llu,", numero); | |
iteraciones++; | |
} | |
return iteraciones; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment