login
a(n) = position of A112046(n) in A000040.
17

%I #27 Mar 13 2021 00:55:51

%S 1,1,2,2,1,1,2,2,1,1,3,3,1,1,2,2,1,1,2,2,1,1,3,4,1,1,2,2,1,1,2,2,1,1,

%T 4,3,1,1,2,2,1,1,2,2,1,1,3,3,1,1,2,2,1,1,2,2,1,1,4,5,1,1,2,2,1,1,2,2,

%U 1,1,3,3,1,1,2,2,1,1,2,2,1,1,3,6,1,1,2,2,1,1,2,2,1,1,4,3,1,1,2,2,1,1

%N a(n) = position of A112046(n) in A000040.

%C A112051 gives the first positions of distinct new values in this sequence, that seem also to be the positions of the first occurrence of each n, and thus the positions of the records. Compare also to A084921. - _Antti Karttunen_, May 26 2017

%H Indranil Ghosh (terms 1..1000) & Antti Karttunen, <a href="/A112049/b112049.txt">Table of n, a(n) for n = 1..32768</a>

%F a(n) = A049084(A112046(n)).

%t a112046[n_]:=Block[{i=1},While[JacobiSymbol[i, 2n + 1]==1, i++]; i];a049084[n_]:=If[PrimeQ[n], PrimePi[n], 0]; Table[a049084[a112046[n]], {n, 102}] (* _Indranil Ghosh_, May 11 2017 *)

%o (PARI) A112049(n) = for(i=1, (2*n), if((kronecker(i, (n+n+1)) < 1), return(primepi(i)))); \\ _Antti Karttunen_, May 26 2017

%o (Python)

%o from sympy import jacobi_symbol as J, isprime, primepi

%o def a049084(n):

%o return primepi(n) if isprime(n) else 0

%o def a112046(n):

%o i=1

%o while True:

%o if J(i, 2*n + 1)!=1: return i

%o else: i+=1

%o def a(n): return a049084(a112046(n))

%o print([a(n) for n in range(1, 103)]) # _Indranil Ghosh_, May 11 2017

%Y Cf. A049084, A112046, A112051, A112060, A165471, A268829, A286465, A286466.

%Y Cf. A286579 (ordinal transform).

%K nonn

%O 1,3

%A _Antti Karttunen_, Aug 27 2005

%E Unnecessary fallback-clause removed from the name by _Antti Karttunen_, May 26 2017