Hofstadter Q sequence: Difference between revisions

Add SETL
imported>Maxima enthusiast
No edit summary
(Add SETL)
Line 3,902:
q(n) < q(n-1) for n = 2 .. 100000: 49798
</pre>
 
=={{header|SETL}}==
<syntaxhighlight lang="setl">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;</syntaxhighlight>
{{out}}
<pre>First 10 terms: [1 1 2 3 3 4 5 5 6 6]
1000th term: 502
q(x) < q(x-1): 49798</pre>
 
=={{header|Sidef}}==
2,094

edits