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.

A290585 a(n) is the largest number <= n such that 1 + a(1)*a(2)*...*a(n) is prime.

Original entry on oeis.org

1, 2, 3, 3, 4, 6, 6, 4, 7, 7, 3, 10, 13, 12, 10, 9, 13, 14, 15, 16, 13, 21, 22, 11, 25, 26, 27, 17, 29, 23, 7, 11, 30, 24, 34, 1, 1, 1, 1, 1, 1, 1, 1, 1, 45, 39, 23, 48, 32, 25, 44, 49, 53, 31, 1, 1, 1, 1, 59, 46, 53, 55, 62, 40, 62, 59, 46, 41, 9, 62, 59, 64, 1, 1, 1, 1, 1, 1, 1, 80, 57, 78, 80, 1, 85
Offset: 1

Views

Author

Thomas Ordowski, Aug 07 2017

Keywords

Comments

a(n) = n for n = 1, 2, 3, 6, 13, 25, 26, 27, 29, 45, 48, 53, 59, 80, 85, ...
If a(n) = 1, then the next entry > 1 is a(m) = m for the least m > n such that 1 + m * Product_{j=1..n-1} a_j is prime. By Dirichlet's theorem such m exists. - Robert Israel, Aug 07 2017

Crossrefs

Programs

  • Maple
    A[1]:= 1: P:= 1:
    for n from 2 to 200 do
      for k from n to 0 by -1 do
        if isprime(1+k*P) then
          A[n]:= k;
          P:= P*k;
          break
        fi
      od;
    od:
    seq(A[i],i=1..200); # Robert Israel, Aug 07 2017
  • Mathematica
    p = 1; Table[t = SelectFirst[Range[n, 1, -1], PrimeQ[1 + p #] &]; p *= t; t, {n, 85}] (* Giovanni Resta, Aug 08 2017 *)
  • PARI
    first(n) = { my(i = 1, res = vector(n)); res[1]=1; for(x=2, n, forstep(k=x, 0, -1, if(ispseudoprime(1+k*i), res[x]=k; i*=k; break()))); res; } \\ Iain Fox, Nov 15 2017
  • Python
    from sympy import isprime
    A=[0, 1]
    p=1
    for n in range(2, 201):
        for k in range(n, -1, -1):
            if isprime(1 + k*p):
                A.append(k)
                p*=k
                break
    print(A[1:]) # Indranil Ghosh, Aug 10 2017
    

Extensions

More terms from Robert Israel, Aug 07 2017