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.

A238847 Smallest k such that k*n^3 + 1 is prime.

Original entry on oeis.org

1, 2, 4, 3, 2, 2, 4, 15, 2, 3, 2, 2, 6, 3, 10, 3, 26, 3, 4, 2, 2, 15, 26, 7, 4, 2, 2, 6, 2, 2, 10, 2, 20, 4, 2, 3, 4, 3, 4, 6, 6, 4, 10, 2, 14, 16, 12, 3, 4, 9, 10, 6, 24, 3, 4, 6, 2, 3, 2, 2, 18, 6, 6, 3, 14, 5, 16, 9, 18, 3, 2, 2, 4, 3, 10, 6
Offset: 1

Views

Author

Derek Orr, Mar 06 2014

Keywords

Examples

			a(1) = 1 because in order for k*(1^3)+1 to be the smallest prime, k must be 1 (1*(1^3)+1 = 2).
a(2) = 2 because in order for k*(2^3)+1 to be the smallest prime, k must be 2 (2*(2^3)+1 = 17).
a(3) = 4 because in order for k*(3^3)+1 to be the smallest prime, k must be 4 (4*(3^3)+1 = 109).
		

Crossrefs

Programs

  • Mathematica
    sk[n_]:=Module[{k=1,n3=n^3},While[!PrimeQ[k*n3+1],k++];k]; Array[sk, 80] (* Harvey P. Dale, Aug 27 2014 *)
    Table[SelectFirst[Range[10^2], PrimeQ[# n^3 + 1] &], {n, 76}] (* Michael De Vlieger, Mar 27 2016, Version 10 *)
  • PARI
    a(n) = {k=1; while(!isprime(k*n^3+1), k++); k;} \\ Altug Alkan, Mar 26 2016
  • Python
    import sympy
    from sympy import isprime
    def f(n):
      for k in range(1,10**3):
        if isprime(k*(n**3)+1):
          return k
    n = 1
    while n < 10**3:
      print(f(n))
      n += 1