Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -0,0 +1,10 @@
hailstone[1] = {1};
hailstone[n_] :=
hailstone[n] = Prepend[hailstone[If[EvenQ[n], n/2, 3 n + 1]], n];
If[$ScriptCommandLine[[1]] == $Input,
val = hailstone[27];
Print["hailstone(27) starts with ", val[[;; 4]], ", ends with ",
val[[-4 ;;]], ", and has length ", Length[val], "."];
val = MaximalBy[Range[99999], Length@*hailstone][[1]];
Print[val, " has the longest hailstone sequence with length ",
Length[hailstone[val]], "."]];

View file

@ -0,0 +1,3 @@
<< hailstone.m;
Print["The most common hailstone length is ",
Commonest[Length@*hailstone /@ Range[99999]][[1]], "."];