A300816 Minimal sequence whose forwards van Eck transform is the sequence of nonprime numbers.
0, 0, 1, 2, 3, 0, 4, 5, 1, 6, 7, 2, 8, 3, 9, 0, 10, 11, 4, 12, 13, 5, 14, 1, 15, 6, 16, 17, 7, 18, 19, 2, 20, 8, 21, 3, 22, 23, 9, 24, 0, 25, 10, 26, 11, 27, 4, 28, 29, 12, 30, 31, 13, 32, 5, 33, 14, 34, 1, 35, 15, 36, 37, 6, 38, 16, 39, 17, 40, 41, 7, 42, 43, 18
Offset: 1
Examples
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.
Programs
-
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);
Comments