Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 16, 2022 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/1f75ddba885910e8d360a8a19de9ae51 to your computer and use it in GitHub Desktop.
Save parzibyte/1f75ddba885910e8d360a8a19de9ae51 to your computer and use it in GitHub Desktop.
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