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-3 of 3 results.

A282687 a(n) = strictly increasing number m, such that m+n is the next prime and m-n is the previous prime.

Original entry on oeis.org

4, 5, 26, 93, 144, 157, 300, 1839, 1922, 3099, 3240, 4189, 5544, 5967, 6506, 10815, 11760, 12871, 30612, 33267, 35002, 36411, 81486, 86653, 95676, 103263, 106060, 153219, 181332, 189097, 190440, 288615, 294596, 326403, 399318, 507253, 515004, 570291, 642320
Offset: 1

Views

Author

Daniel Suteu, Feb 20 2017

Keywords

Examples

			For n = 5, a(5) = 144, because the next prime after 144 is 149 and the previous prime before 144 is 139, where both have an equal distance of 5 from 144.
		

Crossrefs

Programs

  • Mathematica
    a = {}; Do[If[n == 1, k = 1, k = Max@ a + 1]; While[Nand[k - n == NextPrime[k, -1], k + n == NextPrime@ k], k++]; AppendTo[a, k], {n, 41}]; a (* Michael De Vlieger, Feb 20 2017 *)
  • Perl
    use ntheory qw(:all);
    for (my ($n, $k) = (1, 1) ; ; ++$n) {
        my $p = prev_prime($n) || next;
        my $q = next_prime($n);
        if ($n-$p == $k and $q-$n == $k) {
            printf("%s %s\n", $k++, $n);
        }
    }

A306475 Smallest nonprime number <= 10^n (n>=1) with maximum distance from a prime.

Original entry on oeis.org

9, 93, 897, 9569, 31433, 492170, 4652430, 47326803, 436273150, 4302407536, 42652618575, 738832928197, 7177162612050, 90874329411895, 218209405436996, 1693182318746937, 80873624627235459, 804212830686678390
Offset: 1

Views

Author

David Cobac, Feb 18 2019

Keywords

Comments

Each number is a mean of two consecutive primes.
Since, except 2, primes are odd numbers, this mean is an integer.

Examples

			For n=1: first prime numbers are 2, 3, 5, 7 and 11. Maximum difference between two consecutive primes is 4 between 7 and 11 thus a(1)=9.
For n=4: maximum difference between two primes less than 10^4 is 36, which occurs once: between 9551 and 9587. a(4)=(9551 + 9587)/2 = 9569.
		

Crossrefs

Extensions

More terms (using the b-file at A002386) from Jon E. Schoenfield, Feb 19 2019

A353089 Least number which differs from both of its prime neighbors by n^2, and -1 if no such number exists.

Original entry on oeis.org

4, 93, 532, 5607, 31932, 31433, 604122, 3851523, 39175298, 378044079, 367876650, 383204683, 22076314482
Offset: 1

Views

Author

Jean-Marc Rebert, Apr 22 2022

Keywords

Comments

a(12) < 1294268635 is the first term where the first formula is a strict inequality. - Michael S. Branicky, Apr 22 2022

Examples

			a(1) = 4, because 3 and 5 are the prime neighbors of 4, and 5 - 4 = 4 - 3 = 1 = 1^2 and no number less than 4 differs from both of its prime neighbors by 1^2.
a(2) = 93, because 97 and 89 are the prime neighbors of 93, and 97 - 93 = 93 - 89 = 4 = 2^2 and no number less than 93 differs from both of its prime neighbors by 2^2.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := a[n] = Module[{diff, diff2, p, q, r},
         {diff, diff2, p} = {n*n, 2*n*n, NextPrime[1 + n^2]};
         q = NextPrime[p];
         r = NextPrime[q];
         While[!(q - p == diff2 || (q - p == diff && r - q == diff)),
              {p, q, r} = {q, r, NextPrime[r]}];
         Return[If[q - p == diff2, Floor[(q + p)/2], q]]];
    Table[Print[n, " ", a[n]]; a[n], {n, 1, 10}] (* Jean-François Alcover, Jun 07 2022, after Michael S. Branicky's code *)
  • PARI
    a(n) = my(k=2); while (((nextprime(k+1)-k) != n^2) || ((k-precprime(k-1)) != n^2), k++); k; \\ Michel Marcus, Jul 10 2022
  • Python
    from sympy import nextprime
    def a(n):
        diff, diff2, p = n*n, 2*n*n, nextprime(1+n**2)
        q = nextprime(p)
        r = nextprime(q)
        while not (q-p == diff2 or (q-p == diff and r-q == diff)):
            p, q, r = q, r, nextprime(r)
        return (q+p)//2 if q-p == diff2 else q
    print([a(n) for n in range(1, 9)]) # Michael S. Branicky, Apr 22 2022
    

Formula

a(n) <= A000040(A038664(n^2)) + n^2. - Alois P. Heinz, Apr 22 2022
a(n) <= A000230(n^2) + n^2. - David A. Corneth, May 02 2022
a(n) = A282690(n^2). - Michel Marcus, Jul 10 2022

Extensions

a(13) from Michael S. Branicky, Apr 24 2022
Showing 1-3 of 3 results.