Van Eck sequence: Difference between revisions

Add CLU
(Add Modula-2)
(Add CLU)
Line 1,031:
<pre>First 10 terms: (0 0 1 0 2 0 2 2 1 6)
Terms 991 to 1000 terms: (4 7 30 25 67 225 488 0 10 136)</pre>
 
=={{header|CLU}}==
<lang clu>% Generate the first N elements of the Van Eck sequence
eck = proc (n: int) returns (array[int])
ai = array[int]
e: ai := ai$fill(0, n, 0)
for i: int in int$from_to(ai$low(e), ai$high(e)-1) do
for j: int in int$from_to_by(i-1, ai$low(e), -1) do
if e[i] = e[j] then
e[i+1] := i-j
break
end
end
end
return(e)
end eck
 
% Show 0..9 and 990..999
start_up = proc ()
po: stream := stream$primary_output()
e: array[int] := eck(1000)
stream$puts(po, " 0 - 9: ")
for i: int in int$from_to(0,9) do
stream$putright(po, int$unparse(e[i]), 4)
end
stream$puts(po, "\n990 - 999: ")
for i: int in int$from_to(990,999) do
stream$putright(po, int$unparse(e[i]), 4)
end
stream$putl(po, "")
end start_up</lang>
{{out}}
<pre> 0 - 9: 0 0 1 0 2 0 2 2 1 6
990 - 999: 4 7 30 25 67 225 488 0 10 136</pre>
 
=={{header|COBOL}}==
2,114

edits