login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Primes that can be represented in the form b^n+1 or b^n-1 where b >= 2 and n >= 2.
1

%I #39 Jan 08 2018 21:01:50

%S 3,5,7,17,31,37,101,127,197,257,401,577,677,1297,1601,2917,3137,4357,

%T 5477,7057,8101,8191,8837,12101,13457,14401,15377,15877,16901,17957,

%U 21317,22501,24337,25601,28901,30977,32401,33857,41617,42437,44101,50177,52901

%N Primes that can be represented in the form b^n+1 or b^n-1 where b >= 2 and n >= 2.

%C Union of A000668 and A121326. - _Andrey Zabolotskiy_, Dec 21 2017

%H Robert Israel, <a href="/A296422/b296422.txt">Table of n, a(n) for n = 1..10000</a>

%p N:= 10^5: # to get terms <= N

%p R:= 3:

%p for b from 2 while b^2+1 <= N do

%p p:= 2:

%p do

%p p:= nextprime(p);

%p if b^p-1 > N then break fi;

%p if isprime(b^p-1) then R:= R, b^p-1 fi;

%p od:

%p p:= 1:

%p do

%p p:= 2*p;

%p if b^p+1 > N then break fi;

%p if isprime(b^p+1) then R:= R, b^p+1 fi;

%p od;

%p od:

%p sort(convert({R},list)); # _Robert Israel_, Jan 08 2018

%t Select[Prime@ Range[2, 10^4], AnyTrue[# + {-1, 1}, Or[# == 1, GCD @@ FactorInteger[#][[All, -1]] > 1] &] &] (* _Michael De Vlieger_, Dec 13 2017 *)

%o (PARI) lista(nn) = {forprime(p=2, nn, if ((p==2) || ispower(p+1) || ispower(p-1), print1(p, ", ")); ); } \\ _Michel Marcus_, Dec 13 2017

%Y Cf. A000040 (primes), A001597 (perfect powers).

%Y Cf. A000668 (Mersenne primes), A121326.

%K nonn

%O 1,1

%A _Nathaniel J. Strout_, Dec 12 2017