Skip to content

Instantly share code, notes, and snippets.

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 VitamintK/5a55a214b7cdfb0ee557 to your computer and use it in GitHub Desktop.
Save VitamintK/5a55a214b7cdfb0ee557 to your computer and use it in GitHub Desktop.
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}]]
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