% 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