Hofstadter Q sequence: Difference between revisions

Add Draco
(Add CLU)
(Add Draco)
Line 1,370:
print("value is smaller than previous $count times");
}</lang>
 
=={{header|Draco}}==
<lang draco>proc nonrec make_Q([*] word q) void:
word n;
q[1] := 1;
q[2] := 1;
for n from 3 upto dim(q,1)-1 do
q[n] := q[n-q[n-1]] + q[n-q[n-2]]
od
corp
 
proc nonrec main() void:
word MAX = 1000;
word i;
[MAX+1] word q;
make_Q(q);
write("The first 10 terms are:");
for i from 1 upto 10 do write(" ", q[i]) od;
writeln();
writeln("The 1000th term is: ", q[1000])
corp</lang>
{{out}}
<pre>The first 10 terms are: 1 1 2 3 3 4 5 5 6 6
The 1000th term is: 502</pre>
 
=={{header|EchoLisp}}==
2,100

edits