Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
31
Task/Van-Eck-sequence/CLU/van-eck-sequence.clu
Normal file
31
Task/Van-Eck-sequence/CLU/van-eck-sequence.clu
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
% 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue