Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/Hailstone-sequence/Maple/hailstone-sequence-1.maple
Normal file
12
Task/Hailstone-sequence/Maple/hailstone-sequence-1.maple
Normal 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;
|
||||
7
Task/Hailstone-sequence/Maple/hailstone-sequence-2.maple
Normal file
7
Task/Hailstone-sequence/Maple/hailstone-sequence-2.maple
Normal 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]
|
||||
9
Task/Hailstone-sequence/Maple/hailstone-sequence-3.maple
Normal file
9
Task/Hailstone-sequence/Maple/hailstone-sequence-3.maple
Normal 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);
|
||||
Loading…
Add table
Add a link
Reference in a new issue