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

A377848 Even numbers which are the sum of two palindromic primes.

Original entry on oeis.org

4, 6, 8, 10, 12, 14, 16, 18, 22, 104, 106, 108, 112, 134, 136, 138, 142, 154, 156, 158, 162, 184, 186, 188, 192, 194, 196, 198, 202, 232, 252, 262, 282, 292, 302, 312, 316, 318, 320, 322, 324, 332, 342, 356, 358, 360, 362, 364, 372, 376, 378, 380, 382, 384, 386
Offset: 1

Views

Author

James S. DeArmon, Nov 09 2024

Keywords

Examples

			The first term is 4 (2+2), the second term is 6 (3+3). The first term involving a double-digit addend is 14 (3+11).
		

Crossrefs

Intersection of A287961 and A005843.

Programs

  • Maple
    digrev:= proc(n) local L,i;
      L:= convert(n,base,10);
      add(L[-i]*10^(i-1),i=1..nops(L))
    end proc:
    F:= proc(d) # d-digit palindromic primes, d>=3 odd
     local R,x,rx,i;
        select(isprime,map(t -> seq(10^((d+1)/2)*t + i*10^((d-1)/2) + digrev(t),i=0..9), [$(10^((d-3)/2)) .. 10^((d-1)/2)-1]))
    end proc:
    PP:= [3,5,7,11,op(F(3))]: nPP:= nops(PP):
    A:= {4,seq(seq(PP[i] + PP[j],j=1..i),i=1..nPP)}:
    sort(convert(A,list)); # Robert Israel, Dec 15 2024
  • PARI
    ispal(x) = my(d=digits(x)); d == Vecrev(d);
    isok(k) = if (!(k%2), forprime(p=2, k\2, if (ispal(p) && isprime(k-p) && ispal(k-p), return(1)))); \\ Michel Marcus, Nov 15 2024
  • Python
    from sympy import isprime
    from itertools import combinations_with_replacement
    def is_palindrome(n):
        return str(n) == str(n)[::-1]
    palPrimes = set(); sums = set([4]) ; # init sum of 2+2
    sumLimit = 1500 # this limit will generate sufficient sequence length for OEIS DATA section
    # create list of palindrome primes
    for n in range(3,sumLimit):
        if isprime(n) and is_palindrome(n):
            palPrimes.add(n)
    # all combos of 2
    c1 = combinations_with_replacement(palPrimes,2)
    for i,j in c1:
        if (i+j) < sumLimit: sums.add(i+j)
    print(sorted(sums))
    
Showing 1-1 of 1 results.