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,38 @@
$ include "seed7_05.s7i";
const type: intHash is hash [integer] integer;
var intHash: qHash is intHash.value;
const func integer: q (in integer: n) is func
result
var integer: q is 1;
begin
if n in qHash then
q := qHash[n];
else
if n > 2 then
q := q(n - q(pred(n))) + q(n - q(n - 2));
end if;
qHash @:= [n] q;
end if;
end func;
const proc: main is func
local
var integer: n is 0;
var integer: less_than_preceding is 0;
begin
writeln("q(n) for n = 1 .. 10:");
for n range 1 to 10 do
write(q(n) <& " ");
end for;
writeln;
writeln("q(1000)=" <& q(1000));
for n range 2 to 100000 do
if q(n) < q(pred(n)) then
incr(less_than_preceding);
end if;
end for;
writeln("q(n) < q(n-1) for n = 2 .. 100000: " <& less_than_preceding);
end func;