cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-4 of 4 results.

A181697 Length of the complete Cunningham chain of the first kind starting with prime(n).

Original entry on oeis.org

5, 2, 4, 1, 3, 1, 1, 1, 2, 2, 1, 1, 3, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 6, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 5, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1
Offset: 1

Views

Author

M. F. Hasler, Nov 17 2010

Keywords

Comments

Number of iterations x->2x+1 needed to get a composite number, when starting with prime(n).
prime(n) is in A005384, i.e., a Sophie Germain prime, iff a(n)>1.
a(n) is the least k such that 2^k * (prime(n)+1) - 1 is composite. Note that a(n) is well defined since 2^(p-1) * (p+1) - 1 is divisible by p for odd primes p. - Jianing Song, Nov 24 2021

Examples

			2 -> 5 -> 11 -> 23 -> 47 -> 95 = 5*19, so a(1) = 5, a(3) = 4, a(5) = 3, a(9) = 2, and a(15) = 1. - _Jonathan Sondow_, Oct 30 2015
		

Crossrefs

Programs

  • Mathematica
    Table[p = Prime[n]; cnt = 1; While[p = 2*p + 1; PrimeQ[p], cnt++]; cnt, {n, 100}] (* T. D. Noe, Jul 12 2012 *)
  • 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
max(a(n), A181715(n)) = A263879(n) for n > 2. - Jonathan Sondow, Oct 30 2015

Extensions

Definition clarified by Jonathan Sondow, Oct 28 2015

A075712 Rearrangement of primes into Germain groups (or Cunningham chains).

Original entry on oeis.org

2, 5, 11, 23, 47, 3, 7, 13, 17, 19, 29, 59, 31, 37, 41, 83, 167, 43, 53, 107, 61, 67, 71, 73, 79, 89, 179, 359, 719, 1439, 2879, 97, 101, 103, 109, 113, 227, 127, 131, 263, 137, 139, 149, 151, 157, 163, 173, 347, 181, 191, 383, 193, 197, 199, 211, 223, 229, 233
Offset: 1

Views

Author

Zak Seidov, Oct 03 2002

Keywords

Comments

In each group, p(i+1) = 2*p(i)+1.
The groups are also known as Cunningham chains of the first kind.

Examples

			The groups are:
{2, 5, 11, 23, 47},
{3, 7},
{13},
{17},
{19},
{29, 59},
{31},
{37},
{41, 83, 167},
{43},
{53, 107},
{61},
{67},
{71},
{73},
{79},
{89, 179, 359, 719, 1439, 2879},
{97},
{101},
{103},
{109},
{113, 227},
{127},
{131, 263},
{137},
{139},
...
		

Crossrefs

See also A181697.
See A059456 for initial terms, A338945 for lengths.

Programs

  • Mathematica
    Block[{a = {2}, j = 1, k, p}, Do[k = j; If[PrimeQ@ a[[-1]], AppendTo[a, 2 a[[-1]] + 1], While[! FreeQ[a, Set[p, Prime[k]]], k++]; j++; Set[a, Append[a[[1 ;; -2]], p]]], 10^3]; a] (* Michael De Vlieger, Nov 17 2020 *)
  • PARI
    first(n) = my(res=List([2,5,11,23,47])); forprime(p=3, oo, if(!isprime((p-1)>>1), listput(res,p); c = 2*p+1; while(isprime(c), listput(res,c); c=2*c+1)); if(#res>n,return(res))); res \\ David A. Corneth, Nov 13 2021

Extensions

Edited by N. J. A. Sloane, Nov 13 2021
More terms from David A. Corneth, Nov 13 2021

A338946 Lengths of Cunningham chains of the second kind that are sorted by first prime in the chain.

Original entry on oeis.org

3, 2, 1, 1, 3, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 3, 2, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 3, 1, 1, 1, 1, 1, 1
Offset: 1

Views

Author

Michael De Vlieger, Nov 17 2020

Keywords

Comments

Row lengths of A338944.

Examples

			We start with p = 2. Since 2(2) - 1 = 3 is prime, and further 2(3) - 1 = 5 is prime, but 2(5) - 1 is composite, we have chain length 3, so a(1) = 3.
p = 7 is the smallest prime that hasn't appeared in a chain thus far; since 2(7) - 1 = 13 is prime but 2(13) - 1 = 25 is composite, we have a chain of length 2, so a(2) = 2.
p = 11 is the smallest prime that hasn't appeared in a chain; 2(11) - 1 = 21 is composite, so we have a singleton chain, thus a(3) = 1, etc.
		

Crossrefs

Programs

  • Mathematica
    Block[{a = {2}, b = {}, j = 0, k, p}, Do[k = Length@ b + 1; If[PrimeQ@ a[[-1]], AppendTo[a, 2 a[[-1]] - 1]; j++, While[! FreeQ[a, Set[p, Prime[k]]], k++]; AppendTo[b, j]; Set[j, 0]; Set[a, Append[a[[1 ;; -2]], p]]], {10^3}]; b]

A348855 a(1) = 1. If a(n) is prime, a(n+1) = 2*a(n) + 1. If a(n) is not prime, a(n+1) = least prime not already in the sequence.

Original entry on oeis.org

1, 2, 5, 11, 23, 47, 95, 3, 7, 15, 13, 27, 17, 35, 19, 39, 29, 59, 119, 31, 63, 37, 75, 41, 83, 167, 335, 43, 87, 53, 107, 215, 61, 123, 67, 135, 71, 143, 73, 147, 79, 159, 89, 179, 359, 719, 1439, 2879, 5759, 97, 195, 101, 203, 103, 207, 109, 219, 113, 227, 455
Offset: 1

Views

Author

David James Sycamore, Nov 01 2021

Keywords

Comments

The sequence exhibits consecutive terms of "nearly doubled primes", namely Cunningham Chains (of the first kind), the first of which is 2,5,11,23,47. Each prime in such a chain, except for the last is a term in A005384, and each prime except the first is a term in A005385. Every chain is terminated by composite number m = 2*q + 1, where q is the last prime in the chain. At this point the sequence resets to the smallest prime which has not yet been seen, from which the next chain is propagated, and so on. Since by definition every prime appears, so does every possible Cunningham chain. A similar (companion) sequence can be defined using a(n+1) = 2*a(n) - 1 for a(n) a prime term.

Examples

			a(1) = 1 is not prime, so a(2) = 2, the smallest prime not seen so far. Then a(3) = 2*2 + 1 = 5, a(4) = 2*5 + 1 = 11, and so on, generating the chain 2,5,11,23,47.
47 is not a term in A005384 since 2*47 + 1 = 95 is not prime, after which the sequence resets to 3, the least unused prime so far, from which the next chain 3,7,15 arises, and so on.
As an irregular table (each row after the first beginning with a prime and ending with a nonprime), the sequence begins:
1;
2, 5, 11, 23, 47, 95;
3, 7, 15;
13, 27;
17, 35;
19, 39;
29, 59, 119;
31, 63;
37, 75;
41, 83, 167, 335;
43, 87; ...
		

Crossrefs

Programs

  • Mathematica
    a[1]=1;a[n_]:=a[n]=If[PrimeQ@a[n-1],2a[n-1]+1,k=2;While[MemberQ[Array[a,n-1],k],k=NextPrime@k];k];Array[a,60] (* Giorgos Kalogeropoulos, Nov 02 2021 *)
  • Python
    from sympy import isprime, nextprime
    def aupton(terms):
        alst, aset = [1], {1}
        while len(alst) < terms:
            if isprime(alst[-1]):
                an = 2*alst[-1] + 1
            else:
                p = 2
                while p in aset: p = nextprime(p)
                an = p
            alst.append(an); aset.add(an)
        return alst
    print(aupton(60)) # Michael S. Branicky, Nov 02 2021
Showing 1-4 of 4 results.