Skip to content

Instantly share code, notes, and snippets.

Created June 30, 2015 23:55
Show Gist options
  • Save anonymous/742cd68524bbb93fc6a9 to your computer and use it in GitHub Desktop.
Save anonymous/742cd68524bbb93fc6a9 to your computer and use it in GitHub Desktop.
cf =
Compile[
{},
Module[
{n1, l, max = 0, maxN = 0},
Do[
n1 = n;
l = 1;
While[
n1 != 1,
n1 = If[EvenQ[n1], n1/2, 3 n1 + 1];
l++];
If[l > max, max = l; maxN = n];,
{n, 1, 10^4}];
{max, maxN}]]
cf3 =
Compile[
{},
Module[
{n1, l, max = 0, maxN = 0},
Do[
n1 = n;
l = 1;
While[
n1 != 1,
n1 = If[EvenQ[n1], n1~Quotient~2, 3 n1 + 1];
l++];
If[l > max, max = l; maxN = n];,
{n, 1, 10^4}];
{max, maxN}]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment