A181715 Length of the complete Cunningham chain of the second kind starting with prime(n).
3, 2, 1, 2, 1, 1, 1, 3, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 3, 2, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1
Offset: 1
Keywords
Examples
2 -> 3 -> 5 -> 9 = 3^2, so a(1) = 3 and a(2) = 2. - _Jonathan Sondow_, Oct 30 2015
Links
- T. D. Noe, Table of n, a(n) for n = 1..10000
- G. Löh, Long chains of nearly doubled primes, Math. Comp., 53 (1989), 751-759.
- Michael Penn, Romanian Mathematical Olympiad Problem, Youtube video, 2020.
- Wikipedia, Cunningham chain
Crossrefs
Programs
-
Maple
a := proc(n) local c, l: c, l := 0, ithprime(n): while isprime(l) do c, l := c+1, 2*l-1: od: c: end: # Lorenzo Sauras Altuzarra, Feb 12 2021
-
Mathematica
Table[p = Prime[n]; cnt = 1; While[p = 2*p - 1; PrimeQ[p], cnt++]; cnt, {n, 100}] (* T. D. Noe, Jul 12 2012 *) Table[-1 + Length@ NestWhileList[2 # - 1 &, Prime@ n, PrimeQ@ # &], {n, 98}] (* Michael De Vlieger, Apr 26 2017 *)
-
PARI
a(n)= n=prime(n); for(c=1,1e9, is/*pseudo*/prime(n=2*n-1) || return(c))
Formula
a(n) < prime(n) for n > 1; see Löh (1989), p. 751. - Jonathan Sondow, Oct 28 2015
Extensions
Escape clause added to definition by N. J. A. Sloane, Feb 19 2021
Escape clause deleted from definition by Jianing Song, Nov 24 2021
Comments