RosettaCodeData/Task/Hofstadter-Q-sequence/SETL/hofstadter-q-sequence.setl
2023-12-16 21:33:55 -08:00

10 lines
294 B
Text

program hofstadter_q;
q := [1,1];
loop for n in [3..100000] do
q(n) := q(n-q(n-1)) + q(n-q(n-2));
end loop;
print("First 10 terms: " + q(1..10));
print("1000th term: " + q(1000));
print("q(x) < q(x-1): " + #[x : x in [2..#q] | q(x) < q(x-1)]);
end program;