OFFSET
1,1
COMMENTS
Except for the initial term a(1)=2, indices k such that A020513(k)=Phi[k](-1) is prime, where Phi is a cyclotomic polynomial.
This is illustrated by the PARI code, although it is probably more efficient to calculate a(n) as 2*A000961(n).
{ a(n)/2 ; n>1 } are also the indices for which A020500(k)=Phi[k](1) is prime.
LINKS
FORMULA
MAPLE
a := n -> `if`(1>=nops(numtheory[factorset](n)), 2*n, NULL):
seq(a(i), i=1..192); # Peter Luschny, Aug 12 2009
MATHEMATICA
Join[{2}, Select[ Range[3, 1000], PrimeQ[ Cyclotomic[#, -1]] &]] (* Robert G. Wilson v, Mar 25 2012 - modified by Paolo Xausa, Aug 30 2024 to include a(1) *)
2*Join[{1}, Select[Range[500], PrimePowerQ]] (* Paolo Xausa, Aug 30 2024 *)
PROG
(PARI) print1(2); for( i=1, 999, isprime( polcyclo(i, -1)) & print1(", ", i)) /* use ...subst(polcyclo(i), x, -2)... in PARI < 2.4.2. It should be more efficient to calculate a(n) as 2*A000961(n) ! */
(Python)
from sympy import primepi, integer_nthroot
def A138929(n):
def f(x): return int(n-1+x-sum(primepi(integer_nthroot(x, k)[0]) for k in range(1, x.bit_length())))
kmin, kmax = 0, 1
while f(kmax) > kmax:
kmax <<= 1
while kmax-kmin > 1:
kmid = kmax+kmin>>1
if f(kmid) <= kmid:
kmax = kmid
else:
kmin = kmid
return kmax<<1 # Chai Wah Wu, Aug 29 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
M. F. Hasler, Apr 04 2008
STATUS
approved