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.

A357133 a(n) is the least prime that is the arithmetic mean of n consecutive primes.

Original entry on oeis.org

5, 127, 79, 101, 17, 269, 491, 727, 53, 23, 71, 181, 29, 31, 37, 43, 563, 331, 883, 283, 173, 307, 157, 113, 353, 571, 347, 89, 263, 139, 179, 1201, 281, 1553, 137, 5167, 347, 563, 2083, 2087, 491, 1867, 353, 463, 1973, 199, 599, 4373, 149, 9929, 277, 463, 1259, 251, 397, 2897, 787, 263, 2161
Offset: 3

Views

Author

J. M. Bergot and Robert Israel, Sep 14 2022

Keywords

Examples

			a(5) = 79 because 79 is the average of the 5 consecutive primes 71, 73, 79, 83, 89, and 79 is the least prime that works.
		

Crossrefs

Programs

  • Maple
    P:= [seq(ithprime(i),i=1..10^5)]:
    S:= ListTools:-PartialSums(P):
    g:= proc(n) local k,r;
       for k from 1 to 10^5-n do
          r:= (S[k+n]-S[k])/n;
          if r::integer and isprime(r) then return r fi
       od;
       -1
    end proc:
    map(g, [$3..100]);
  • Mathematica
    a={}; n=3; For[k=1, k<=1200, k++, If[PrimeQ[p=Sum[Prime[k+i], {i,0,n-1}]/n], AppendTo[a,p]; n++; k=1]]; a (* Stefano Spezia, Sep 15 2022 *)
  • Python
    from itertools import islice
    from sympy import isprime, nextprime
    def agen():
        n, plst0 = 3, [2, 3, 5]
        while True:
            plst = plst0[:]
            while True:
                q, r = divmod(sum(plst), n)
                if r == 0 and isprime(q): yield q; break
                plst = plst[1:] + [nextprime(plst[-1])]
            plst0.append(nextprime(plst0[-1]))
            n += 1
    print(list(islice(agen(), 60))) # Michael S. Branicky, Sep 14 2022