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.

A338446 Numbers that are sums of consecutive odd primes.

Original entry on oeis.org

3, 5, 7, 8, 11, 12, 13, 15, 17, 18, 19, 23, 24, 26, 29, 30, 31, 36, 37, 39, 41, 42, 43, 47, 48, 49, 52, 53, 56, 59, 60, 61, 67, 68, 71, 72, 73, 75, 78, 79, 83, 84, 88, 89, 90, 95, 97, 98, 100, 101, 102, 103, 107, 109, 112, 113, 119, 120, 121, 124, 127, 128, 131, 132, 137
Offset: 1

Views

Author

Ilya Gutkovskiy, Oct 28 2020

Keywords

Examples

			67 is in the sequence because 67 = 7 + 11 + 13 + 17 + 19.
		

Crossrefs

Programs

  • Maple
    q:= proc(n) local p, q, s; p, q, s:= prevprime(n+1)$3;
          do if p=2 then return false
           elif s=n then return true
           elif sAlois P. Heinz, Oct 31 2020
  • Mathematica
    okQ[n_] := Module[{p, q, s}, {p, q, s} = Table[NextPrime[n + 1, -1], {3}]; While[True, Which[
         p == 2, Return@ False,
         s == n, Return@ True,
         s < n, p = NextPrime[p, -1]; s = s + p,
         True, s = s - q; q = NextPrime[q, -1]]]];
    Select[Range[3, 150], okQ] (* Jean-François Alcover, Feb 21 2022, after Alois P. Heinz *)
  • Python
    from sympy import prevprime
    def ok(n):
        if n < 2: return False
        p, q, s = [prevprime(n+1)] * 3
        while True:
            if p == 2: return False
            if s == n: return True
            elif s < n: p = prevprime(p); s += p
            else: s -= q; q = prevprime(q)
    print([k for k in range(150) if ok(k)]) # Michael S. Branicky, Feb 21 2022 after Alois P. Heinz