Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,12 @@
hailstone := proc( N )
local n := N, HS := Array([n]);
while n > 1 do
if type(n,even) then
n := n/2;
else
n := 3*n+1;
end if;
HS(numelems(HS)+1) := n;
end do;
HS;
end proc;

View file

@ -0,0 +1,7 @@
> r := hailstone(27):
[ 1..112 1-D Array ]
r := [ Data Type: anything ]
[ Storage: rectangular ]
[ Order: Fortran_order ]
> r(1..4) ... r(-4..);
[27, 82, 41, 124] .. [8, 4, 2, 1]

View file

@ -0,0 +1,9 @@
longest := 0; n := 0;
for i from 1 to 100000 do
len := numelems(hailstone(i));
if len > longest then
longest := len;
n := i;
end if;
od:
printf("The longest Hailstone sequence in the first 100k is n=%d, with %d terms\n",n,longest);