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.

This page as a plain text file.
%I A338446 #14 Feb 21 2022 23:38:50
%S A338446 3,5,7,8,11,12,13,15,17,18,19,23,24,26,29,30,31,36,37,39,41,42,43,47,
%T A338446 48,49,52,53,56,59,60,61,67,68,71,72,73,75,78,79,83,84,88,89,90,95,97,
%U A338446 98,100,101,102,103,107,109,112,113,119,120,121,124,127,128,131,132,137
%N A338446 Numbers that are sums of consecutive odd primes.
%H A338446 Alois P. Heinz, <a href="/A338446/b338446.txt">Table of n, a(n) for n = 1..10000</a>
%e A338446 67 is in the sequence because 67 = 7 + 11 + 13 + 17 + 19.
%p A338446 q:= proc(n) local p, q, s; p, q, s:= prevprime(n+1)$3;
%p A338446       do if p=2 then return false
%p A338446        elif s=n then return true
%p A338446        elif s<n then p:= prevprime(p); s:= s+p;
%p A338446                 else s:= s-q; q:= prevprime(q)
%p A338446          fi
%p A338446       od
%p A338446     end:
%p A338446 select(q, [$3..150])[];  # _Alois P. Heinz_, Oct 31 2020
%t A338446 okQ[n_] := Module[{p, q, s}, {p, q, s} = Table[NextPrime[n + 1, -1], {3}]; While[True, Which[
%t A338446      p == 2, Return@ False,
%t A338446      s == n, Return@ True,
%t A338446      s < n, p = NextPrime[p, -1]; s = s + p,
%t A338446      True, s = s - q; q = NextPrime[q, -1]]]];
%t A338446 Select[Range[3, 150], okQ] (* _Jean-François Alcover_, Feb 21 2022, after _Alois P. Heinz_ *)
%o A338446 (Python)
%o A338446 from sympy import prevprime
%o A338446 def ok(n):
%o A338446     if n < 2: return False
%o A338446     p, q, s = [prevprime(n+1)] * 3
%o A338446     while True:
%o A338446         if p == 2: return False
%o A338446         if s == n: return True
%o A338446         elif s < n: p = prevprime(p); s += p
%o A338446         else: s -= q; q = prevprime(q)
%o A338446 print([k for k in range(150) if ok(k)]) # _Michael S. Branicky_, Feb 21 2022 after _Alois P. Heinz_
%Y A338446 Cf. A007504, A034707, A050936, A053790, A065091, A071148.
%K A338446 nonn
%O A338446 1,1
%A A338446 _Ilya Gutkovskiy_, Oct 28 2020