Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
|||
HailstoneF[n_] := NestWhileList[If[OddQ[#], 3 # + 1, #/2] &, n, # > 1 &]
|
||||
|
|
@ -0,0 +1 @@
|
|||
HailstoneFP[n_] := Most@FixedPointList[Switch[#, 1, 1, _?OddQ , 3# + 1, _, #/2] &, n]
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
HailstoneR[1] = {1}
|
||||
HailstoneR[n_?OddQ] := Prepend[HailstoneR[3 n + 1], n]
|
||||
HailstoneR[n_] := Prepend[HailstoneR[n/2], n]
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
HailstoneP[n_] := Module[{x = {n}, s = n},
|
||||
While[s > 1, x = {x, s = If[OddQ@s, 3 s + 1, s/2]}]; Flatten@x]
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
Hailstone[n_] :=
|
||||
NestWhileList[If[Mod[#, 2] == 0, #/2, ( 3*# + 1) ] &, n, # != 1 &];
|
||||
|
||||
|
||||
c27 = Hailstone@27;
|
||||
Print["Hailstone sequence for n = 27: [", c27[[;; 4]], "...", c27[[-4 ;;]], "]"]
|
||||
Print["Length Hailstone[27] = ", Length@c27]
|
||||
|
||||
longest = -1; comp = 0;
|
||||
Do[temp = Length@Hailstone@i;
|
||||
If[comp < temp, comp = temp; longest = i],
|
||||
{i, 100000}
|
||||
]
|
||||
Print["Longest Hailstone sequence at n = ", longest, "\nwith length = ", comp];
|
||||
|
|
@ -0,0 +1 @@
|
|||
With[{seq = HailstoneFP[27]}, { Length[seq], Take[seq, 4], Take[seq, -4]}]
|
||||
|
|
@ -0,0 +1 @@
|
|||
Short[HailstoneFP[27],0.45]
|
||||
|
|
@ -0,0 +1 @@
|
|||
MaximalBy[Table[{i, Length[HailstoneFP[i]]}, {i, 100000}], Last]
|
||||
Loading…
Add table
Add a link
Reference in a new issue