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.

A289829 Perfect squares of the form prime(k+1)^2 - prime(k)^2 + 1 where prime(k) is the k-th prime number.

Original entry on oeis.org

25, 49, 121, 169, 289, 361, 841, 961, 1681, 1849, 2401, 2809, 3721, 5929, 6889, 7921, 8281, 10201, 11449, 11881, 14161, 14641, 17689, 24649, 26569, 32041, 38809, 41209, 43681, 44521, 61009, 63001, 69169, 76729, 80089, 85849, 89401, 94249, 96721, 97969, 108241
Offset: 1

Views

Author

Joseph Wheat, Jul 12 2017

Keywords

Examples

			7^2 - 5^2 + 1 = 5^2, 17^2 - 13^2 + 1 = 11^2, 47^2 - 43^2 + 1 = 19^2, etc.
		

Programs

  • Mathematica
    TakeWhile[#, # < 110000 &] &@ Union@ Select[Array[Prime[# + 1]^2 - Prime[#]^2 + 1 &, 10^4], IntegerQ@ Sqrt@ # &] (* Michael De Vlieger, Jul 13 2017 *)
    Take[Select[#[[2]]-#[[1]]+1&/@Partition[Prime[Range[3000]]^2,2,1],IntegerQ[Sqrt[#]]&]//Union,50] (* Harvey P. Dale, Jan 19 2025 *)
  • PARI
    is(n) = if(!issquare(n), return(0), my(p=2); while(1, if(n==nextprime(p+1)^2-p^2+1, return(1)); p=nextprime(p+1); if(p > n, return(0)))) \\ Felix Fröhlich, Jul 15 2017
  • Python
    from _future_ import division
    from sympy import divisors, isprime, prevprime, nextprime
    A289829_list = []
    for n in range(10**4):
        m = n**2-1
        for d in divisors(m):
            if d*d >= m:
                break
            r = m//d
            if not r % 2:
                r = r//2
                if not isprime(r):
                    p, q = prevprime(r), nextprime(r)
                    if m == (q-p)*(q+p):
                        A289829_list.append(n**2)
                        break # Chai Wah Wu, Jul 15 2017
    

Extensions

More terms from Alois P. Heinz, Jul 13 2017