Jump to content

Hofstadter Q sequence: Difference between revisions

Updated to work with Nim 1.4.
(Add MAD)
(Updated to work with Nim 1.4.)
Line 1,800:
=={{header|Nim}}==
<lang nim>var q = @[1, 1]
for n in 2 .. < 100_000: q.add q[n-q[n-1]] + q[n-q[n-2]]
 
echo q[0..9]
Line 1,809:
 
var lessCount = 0
for n in 1 .. < 100_000:
if q[n] < q[n-1]:
inc lessCount
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.