OEIS A400659

← Yagel Numbers in the OEIS

The sequence

OEIS A400659: a(n) is the least k≥1 such that A002110(n−1)⋅prime(n)k−1 is prime.

In the notation of the paper, where Yk(n)=pk−1#⋅pkn−1, the OEIS index n is the order k and the OEIS variable k is the exponent n: a(n) is the exponent of the first prime in row n of the minus face. The first terms are 2, 1, 1, 3, 1, 1, 2, 5, 5, 4, 16, 4, 1, 12, 9, …

Together, the rows of the minus face form the square array A401136, read by antidiagonals. a(n) is the position of the first prime in row n of that array.

How each term is proved

Write Nk=A002110(n−1)⋅prime(n)k−1. A term a(n)=k is established by two kinds of proof.

The Lucas N+1 test (Lucas; Lehmer; Brillhart, Lehmer and Selfridge, 1975). Let N≥3 be odd with F=N+1 completely factored. Suppose there is one integer D with gcd(D,N)=1 and (DN)=−1, and for every prime q∣F an integer Pq2≡D(mod4), with Qq=(Pq2−D)/4, such that

gcd(2Qq,N)=1,UN+1(Pq,Qq)≡0(modN),gcd(U(N+1)/q(Pq,Qq),N)=1,

where U0=0, U1=1, Um+1=PUm−QUm−1. Then every prime r∣N satisfies N+1∣r−(Dr), so r≥N and N is prime. The discriminant D must be the same for every q; only Pq may change. That is what lets the conditions for the different q combine into the single divisibility by N+1.

Check it yourself

Two self-contained programs re-prove every term on your own computer. Neither needs any data from this site:

For each n≤100, each program finds a(n) by testing k=1,2,… in order, proves every smaller exponent composite (for n=1, that N1=1 is not prime) and the term itself prime as described above, prints the witnesses it used, and compares the result with the 100 terms of the b-file, which are embedded in the program.

gp -q A400659.gp
python A400659.py

The last line of the output is

OK: a(1)..a(100) proved and equal to the b-file. Total 184 s.

Times measured on one core of a desktop PC: PARI/GP 2.17.3, 184 s; Python 3.13 with gmpy2, 119 s; Python 3.13 with the standard library only, 1,017 s. These are whole-program timings for the stated runs; they do not isolate multiplication speed. Most of it is the last term: a(100) needs 1,278 composites of up to 3,713 digits (543 settled by a prime factor below 105, 735 by a Fermat test) and a Lucas proof with 100 primes q. Each line says how the smaller exponents were shown composite and gives D, the common P and any primes q that needed a different P. For example:

n=1  a(n)=2  digits=1  k=1 gives N=1 (not prime)  |  k=2 prime: Lucas N+1, D=5, P=1  [0 ms]
n=2  a(n)=1  digits=1  no smaller k  |  k=1 prime: Lucas N+1, D=-7, P=1  [0 ms]
n=4  a(n)=3  digits=5  k<3 composite (2 with a prime factor below 10^5)  |  k=3 prime: Lucas N+1, D=-7, P=1, except (q,P)=[[2, 7]]  [0 ms]
n=26  a(n)=65  digits=167  k<65 composite (38 with a prime factor below 10^5, 26 by a Fermat test, bases [2])  |  k=65 prime: Lucas N+1, D=-7, P=1, except (q,P)=[[83, 9]]  [47 ms]
n=100  a(n)=1279  digits=3713  k<1279 composite (543 with a prime factor below 10^5, 735 by a Fermat test, bases [2])  |  k=1279 prime: Lucas N+1, D=-7, P=1, except (q,P)=[[2, 7]]  [141891 ms]

The two programs implement the same procedure with separate arithmetic: separate prime tables, small-factor tests, Jacobi symbols and arithmetic in the quadratic ring. They use the same search order for D and P, so they print the same lines apart from the timings. Each is therefore a check on the other. If neither a compositeness witness nor a Lucas proof is found, the GP program reports PARI's own isprime verdict and the Python program stops with a message; neither happens for n≤100.

Shorter runs. python A400659.py 30 checks n≤30. In gp, delete the two final lines of the file (verify(); and quit;), load it with \r A400659.gp and call verify(30). Also in gp, crossCheck(1, 60) re-proves the primes at k=a(n) with PARI's own isprime, which shares nothing with the Lucas N+1 code. It is slower: the 900-digit term a(56)=329 takes about two minutes.

Stack size. The gp program raises PARI's stack limit itself (parisizemax, 1 GB). The one-line program in the OEIS entry needs the same setting for larger n: with gp's default 8 MB stack, isprime stops with “the PARI stack overflows” at n=31, whose term is a 529-digit prime. Run default(parisizemax, 2^30) first.

Requirements. PARI/GP 2.13 or later, or Python 3.8 or later (tested with PARI/GP 2.17.3 and Python 3.13). The Python program uses only the standard library; if the optional gmpy2 package is installed it runs faster. Both are free software.

Term table

The table uses the site's coordinates: order k and exponent n. Each a(k) is the first exponent with Yk(n) prime; all smaller exponents are shown nonprime by the verification programs above. In row 1, Y1(1)=1 is neither prime nor composite.

All 100 terms at the OEIS (b-file). Select a prime below to compute its exact value in Explore the Grid.

order k a(k) first prime of the row digits
122² − 11
21p₁#·3¹ − 11
31p₂#·5¹ − 12
43p₃#·7³ − 15
51p₄#·11¹ − 14
61p₅#·13¹ − 15
72p₆#·17² − 17
85p₇#·19⁵ − 113
95p₈#·23⁵ − 114
104p₉#·29⁴ − 115
1116p₁₀#·31¹⁶ − 134
124p₁₁#·37⁴ − 118
131p₁₂#·41¹ − 115
1412p₁₃#·43¹² − 135
159p₁₄#·47⁹ − 132
162p₁₅#·53² − 122
175p₁₆#·59⁵ − 129
183p₁₇#·61³ − 127
196p₁₈#·67⁶ − 135
202p₁₉#·71² − 129
2134p₂₀#·73³⁴ − 191
223p₂₁#·79³ − 135
232p₂₂#·83² − 135
241p₂₃#·89¹ − 135
256p₂₄#·97⁶ − 147
2665p₂₅#·101⁶⁵ − 1167
273p₂₆#·103³ − 145
285p₂₇#·107⁵ − 151
296p₂₈#·109⁶ − 155
303p₂₉#·113³ − 151
31229p₃₀#·127²²⁹ − 1529
3211p₃₁#·131¹¹ − 172
3317p₃₂#·137¹⁷ − 188
345p₃₃#·139⁵ − 164
357p₃₄#·149⁷ − 171
3616p₃₅#·151¹⁶ − 193
3719p₃₆#·157¹⁹ − 1102
3815p₃₇#·163¹⁵ − 195
3946p₃₈#·167⁴⁶ − 1167
4011p₃₉#·173¹¹ − 191
4114p₄₀#·179¹⁴ − 1100
4220p₄₁#·181²⁰ − 1116
4310p₄₂#·191¹⁰ − 196
44207p₄₃#·193²⁰⁷ − 1549
4512p₄₄#·197¹² − 1105
4612p₄₅#·199¹² − 1108
4732p₄₆#·211³² − 1157
4863p₄₇#·223⁶³ − 1233
496p₄₈#·227⁶ − 1101
5093p₄₉#·229⁹³ − 1309
514p₅₀#·233⁴ − 1101
5216p₅₁#·239¹⁶ − 1132
5396p₅₂#·241⁹⁶ − 1325
545p₅₃#·251⁵ − 1111
555p₅₄#·257⁵ − 1113
56329p₅₅#·263³²⁹ − 1900
57172p₅₆#·269¹⁷² − 1524
5834p₅₇#·271³⁴ − 1191
5968p₅₈#·277⁶⁸ − 1277
604p₅₉#·281⁴ − 1123
61395p₆₀#·283³⁹⁵ − 11,084
62150p₆₁#·293¹⁵⁰ − 1488
6320p₆₂#·307²⁰ − 1171
642p₆₃#·311² − 1128
6520p₆₄#·313²⁰ − 1176
661p₆₅#·317¹ − 1131
6754p₆₆#·331⁵⁴ − 1267
681p₆₇#·337¹ − 1136
69106p₆₈#·347¹⁰⁶ − 1405
705p₆₉#·349⁵ − 1151
71103p₇₀#·353¹⁰³ − 1403
7211p₇₁#·359¹¹ − 1172
7320p₇₂#·367²⁰ − 1197
7434p₇₃#·373³⁴ − 1236
7522p₇₄#·379²² − 1208
7663p₇₅#·383⁶³ − 1316
77139p₇₆#·389¹³⁹ − 1516
7848p₇₇#·397⁴⁸ − 1284
7971p₇₈#·401⁷¹ − 1346
8025p₇₉#·409²⁵ − 1229
8155p₈₀#·419⁵⁵ − 1311
8245p₈₁#·421⁴⁵ − 1287
8327p₈₂#·431²⁷ − 1243
8422p₈₃#·433²² − 1233
85119p₈₄#·439¹¹⁹ − 1492
869p₈₅#·443⁹ − 1204
87124p₈₆#·449¹²⁴ − 1511
88470p₈₇#·457⁴⁷⁰ − 11,435
8920p₈₈#·461²⁰ − 1241
9051p₈₉#·463⁵¹ − 1326
916p₉₀#·467⁶ − 1209
9271p₉₁#·479⁷¹ − 1386
9374p₉₂#·487⁷⁴ − 1397
9495p₉₃#·491⁹⁵ − 1457
9583p₉₄#·499⁸³ − 1428
96589p₉₅#·503⁵⁸⁹ − 11,798
97171p₉₆#·509¹⁷¹ − 1672
9830p₉₇#·521³⁰ − 1294
99118p₉₈#·523¹¹⁸ − 1536
1001279p₉₉#·541¹²⁷⁹ − 13,713

Scope

The terms a(1),…,a(100) are proved: each is the result of the computation above, which anyone can repeat. The largest term, a(100)=1279, gives a 3,713-digit prime. It is not known whether a(n) exists for every n.