%I #16 Nov 28 2018 20:58:18
%S 2,1,0,1,0,1,0,1,0,1,2,1,2,1,2,1,0,1,2,1,0,1,0,1,0,1,2,1,0,1,2,1,0,1,
%T 2,1,0,1,0,1,2,1,0,1,0,1,0,1,0,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,
%U 2,1,2,1,2,1,0,1,2,1,2,1,0,1,2,1,0,1,2,1,2,1,2,1,2,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,2,1,2,1,0,1,2
%N a(n) = A215029(A000040(n)), where A000040(n) is the n-th prime.
%C For primes whose value is 0, see A214912; for value 1 see A031215; and for value 2 see A215031.
%H Antti Karttunen, <a href="/A215030/b215030.txt">Table of n, a(n) for n = 1..10000</a>
%H StackExchange, <a href="http://math.stackexchange.com/questions/176394/a-prime-number-pattern">A prime number pattern</a>, Jul 29 2012.
%o (PARI)
%o A215029(n) = if(n<=2,n,my(mp=precprime(n-1),d=n); while(mp>0, if(d>0, d -= mp, d += mp); mp = precprime(mp-1)); (d));
%o A215030(n) = A215029(prime(n)); \\ _Antti Karttunen_, Nov 28 2018
%Y Cf. A000040, A215029, A214912, A031215, A215031, A215032, A215033, A215034, A215035.
%K nonn
%O 1,1
%A _N. J. A. Sloane_, Aug 05 2012