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.

A284327 a(n) is the least positive integer such that n^2 + a(n)^2 and n^2 + (a(n) - 2)^2 are primes.

Original entry on oeis.org

1, 1, 10, 1, 4, 1, 10, 5, 16, 1, 6, 25, 10, 1, 4, 1, 10, 7, 16, 1, 46, 15, 20, 1, 6, 1, 22, 15, 6, 13, 6, 5, 190, 11, 18, 1, 30, 15, 46, 1, 46, 25, 10, 21, 16, 21, 10, 37, 6, 19, 16, 5, 12, 1, 6, 1, 52, 5, 26, 31, 26, 45, 40, 11, 4, 1, 20, 7, 196, 19, 16
Offset: 1

Views

Author

Lars-Erik Svahn, Mar 25 2017

Keywords

Comments

n + i*a(n) and n + i*(a(n) - 2) are Gaussian twin primes.
If n^2 + 1 is a prime then a(n) = 1 else a(n) = A284211(n) + 2.

Examples

			a(1) = 1 since 1^2 + 1^2 = 2 and 1^2 + (1 - 2)^2 = 2 are primes.
		

Crossrefs

Programs

  • Mathematica
    Rest@ FoldList[Module[{k = 1}, While[Times @@ Boole@ Map[PrimeQ, {#2^2 + k^2, #2^2 + (k - 2)^2}] < 1, k++]; k] &, 1, Range@ 71] (* Michael De Vlieger, Mar 25 2017 *)
  • PARI
    a(n) = k=0; while (! (isprime(n^2+k^2) && isprime(n^2+(k-2)^2)), k++); k; \\ Michel Marcus, Mar 25 2017
    
  • Python
    from sympy import isprime
    def a(n):
        k=0
        while True:
            if isprime(n**2 + k**2) and isprime(n**2 + (k - 2)**2): return k
            else: k+=1
    print([a(n) for n in range(1, 101)]) # Indranil Ghosh, Mar 31 2017

Formula

a(n) = 1 for n in A005574. - Michel Marcus, Mar 31 2017