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.

A046328 Palindromes with exactly 2 prime factors (counted with multiplicity).

Original entry on oeis.org

4, 6, 9, 22, 33, 55, 77, 111, 121, 141, 161, 202, 262, 303, 323, 393, 454, 505, 515, 535, 545, 565, 626, 707, 717, 737, 767, 818, 838, 878, 898, 939, 949, 959, 979, 989, 1111, 1441, 1661, 1991, 3113, 3223, 3443, 3883, 7117, 7447, 7997, 9119, 9229, 9449, 10001
Offset: 1

Views

Author

Patrick De Geest, Jun 15 1998

Keywords

Examples

			111 is a palindrome and 111 = 3*37. 3 and 37 are primes.
		

Crossrefs

Subsequence of A001358 and A046338.

Programs

  • Mathematica
    fQ[n_] := Block[{id = IntegerDigits[n]}, Plus @@ Last /@ FactorInteger[n] == 2 && id == Reverse[id]]; Select[ Range[ 10000], fQ[ # ] &] (* Robert G. Wilson v, Jun 06 2005 *)
    Select[Range[10002], Reverse[x = IntegerDigits[#]] == x && PrimeOmega[#] == 2 &] (* Jayanta Basu, Jun 23 2013 *)
    Select[Range[11000],PalindromeQ[#]&&PrimeOmega[#]==2&] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Apr 30 2018 *)
  • PARI
    ispal(n) = my(d=digits(n));d == Vecrev(d) \\ A002113
    for(k=1,1e4,if(ispal(k)&&bigomega(k)==2, print1(k, ", "))) \\ Alexandru Petrescu, Jul 07 2022
    
  • Python
    from sympy import factorint
    from itertools import product
    def ispal(n): s = str(n); return s == s[::-1]
    def pals(d, base=10): # all d-digit palindromes
        digits = "".join(str(i) for i in range(base))
        for p in product(digits, repeat=d//2):
            if d > 1 and p[0] == "0": continue
            left = "".join(p); right = left[::-1]
            for mid in [[""], digits][d%2]: yield int(left + mid + right)
    def ok(pal): return sum(factorint(pal).values()) == 2
    print(list(filter(ok, (p for d in range(1, 6) for p in pals(d) if ok(p))))) # Michael S. Branicky, Aug 14 2022