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.

A381869 Smallest starting prime for which the sum of 2*n consecutive primes is 0 modulo 10, or -1 if no such prime exists.

Original entry on oeis.org

13, 11, 7, 7, 13, 17, 7, 17, 37, 3, 7, 41, 7, 7, 11, 11, 11, 11, 11, 13, 11, 13, 11, 7, 7, 17, 7, 43, 41, 3, 3, 13, 11, 7, 13, 19, 7, 11, 11, 29, 7, 43, 3, 7, 11, 13, 23, 29, 3, 7, 7, 11, 11, 11, 19, 13, 5, 5, 13, 37, 17, 3, 3, 7, 17, 17, 3, 11, 19, 13, 3, 7, 23
Offset: 1

Views

Author

Jean-Marc Rebert, Mar 09 2025

Keywords

Examples

			a(1) = 13, because 13 and 17 are 2*1 = 2 consecutive primes such that 13 + 17 = 20 and 20 modulo 10 = 0, and no smaller prime has this property.
		

Crossrefs

Programs

  • Maple
    P:= select(isprime,[2,seq(i,i=3..10^6,2)]):
    S:= ListTools:-PartialSums(P):
    f:= proc(n) local j,t;
      for j from 1 do
        if S[2*n+j] - S[j] mod 10 = 0 then return P[j+1] fi
      od
    end proc:
    map(f, [$1..100]); # Robert Israel, May 08 2025
  • Mathematica
    Do[i=1;Until[Mod[Total[Prime[Range[i,i+2*n-1]]],10]==0,i++];a[n]=Prime[i],{n,73}];Array[a,73] (* James C. McMahon, Mar 23 2025 *)
  • PARI
    isok(p, n) = my(i=primepi(p), q=prime(2*n+i-1)); vecsum(apply(x->Mod(x,10), primes([p, q]))) == 0;
    a(n) = my(p=3); while (!isok(p, n), p=nextprime(p+1)); p; \\ Michel Marcus, Mar 09 2025
    
  • Python
    from sympy import nextprime, prime, sieve
    def a(n):
        plst = list(sieve.primerange(3, prime(2*n+1)+1))
        s = sum(plst)
        while s%10:
            q = nextprime(plst[-1])
            s += (q-plst[0])
            plst = plst[1:] + [q]
        return plst[0]
    print([a(n) for n in range(1, 74)]) # Michael S. Branicky, Mar 09 2025