OFFSET
1,4
COMMENTS
At each step, the minimum available integer is used.
EXAMPLE
a(1) = 0. Next 0 is at distance 1: a(2) = 0.
a(2) = 0. Next 0 is at distance 4: a(6) = 0.
For a(3) we cannot use 0 because the next 0 is at distance 3 that is a prime.
Therefore we must use 1: a(3) = 1.
Next 1 must be at distance 6, next composite after 4: a(9) = 1.
Again, for a(4) we cannot use neither 0 nor 1: a(4) = 2.
Next 2 must be at distance 8: a(12) = 2. And so on.
MAPLE
P:=proc(q, h) local i, k, n, t, x; x:=array(1..h);
for k from 1 to h do x[k]:=-1; od; x[1]:=0; i:=0; t:=0;
for n from 1 to q do if not isprime(n) then i:=i+1;
if x[i]=-1 then t:=t+1; x[i]:=t; fi; x[i+n]:=x[i];
fi; od; seq(x[k], k=1..124); end: P(160, 300);
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Paolo P. Lava, Mar 13 2018
STATUS
approved