%I #39 Sep 16 2022 17:38:56
%S 7,5,2,105,3,909,4995825,28212939,4836335472639,223671748721751
%N Records in A245509: smallest m > 1 such that the first odd number greater than m^k is prime for every 0 < k < n, but not for k = n.
%C For more comments and a program, see A245509. a(9), if it exists, certainly exceeds 1050000000. It is not clear whether this sequence is infinite, nor whether a(n) is defined for every n.
%C For n > 3, a(n) is always odd, because A245509(i) can exceed 3 only when i is odd. Therefore to find more terms, it suffices to find odd bases m such that m+2, m^2+2, m^3+2, m^4+2, ..., m^N+2 is a long list of primes. - _Jeppe Stig Nielsen_, Sep 09 2022
%C From _Jon E. Schoenfield_, Sep 09 2022: (Start)
%C For any term m beyond a(8) that exists, each of the following holds:
%C m = p - 2, where p is a prime (so m is odd);
%C m == 0 (mod 3);
%C m == {-1, 0, 1} (mod 5);
%C m == {-1, 0, 1} (mod 11);
%C consequently, m mod 330 is one of 9 values: {21, 45, 99, 111, 165, 219, 231, 285, 309}.
%C (End)
%H MathOverflow, <a href="https://mathoverflow.net/questions/429988/">Primes of the form a + b^k for k=(a mod 2), ..., n?</a>
%e a(4) = 105 because 105 is the smallest m such that the first odd numbers after m^k are prime for k = 1,2,3, but composite for k = 4.
%e 909+2, 909^2+2, 909^3+2, 909^4+2 and 909^5+2 are five primes, but 909^6+2 is composite, and 909 is minimal with this property. Therefore, a(6)=909 (and A245509(909)=6). - _Jeppe Stig Nielsen_, Sep 09 2022
%t f[n_] := Block[{d = If[ OddQ@ n, 2, 1], m = 1, t}, While[t = n^m + d; EvenQ@ t || PrimeQ@ t, m++]; m]; t = Table[0, {25}]; k = 2; While[k < 29000000, a = f@ k; If[ t[[a]] == 0, t[[a]] = k; Print[{a, k}]]; k++]; t (* _Robert G. Wilson v_, Aug 04 2014 *)
%o (PARI) a(n) = for(k=1, oo, c=0; for(i=1, n-1, if(isprime(k^i+(k%2)+1), c++)); if(c==n-1&&!isprime(k^n+(k%2)+1), return(k)))
%o n=1; while(n<10, print1(a(n),", "); n++) \\ _Derek Orr_, Jul 27 2014
%o (PARI) upto(n)=v=vector(n);forstep(m=3,+oo,2,k=1;while(ispseudoprime(m^k+2),k++);if(k<=n&&v[k]==0,v[k]=m-(k==3)*7;print(v);vecprod(v)!=0&&return(v))) \\ _Jeppe Stig Nielsen_, Sep 09 2022
%Y Cf. A245509, A245511, A245512, A245513, A245514.
%K nonn,hard,more
%O 1,1
%A _Stanislav Sykora_, Jul 24 2014
%E a(4) and example corrected by _Derek Orr_, Jul 27 2014
%E a(8) from _Robert G. Wilson v_, Aug 04 2014
%E a(9) from _Kellen Shenton_, Sep 14 2022
%E a(10) from _Kellen Shenton_, Sep 16 2022