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

A152242 Integers formed by concatenating primes.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 19, 22, 23, 25, 27, 29, 31, 32, 33, 35, 37, 41, 43, 47, 52, 53, 55, 57, 59, 61, 67, 71, 72, 73, 75, 77, 79, 83, 89, 97, 101, 103, 107, 109, 112, 113, 115, 117, 127, 131, 132, 133, 135, 137, 139, 149, 151, 157, 163, 167, 172, 173, 175, 177, 179
Offset: 1

Views

Author

Eric Angelini, Oct 15 2009

Keywords

Comments

Leading zeros are not allowed (cf. A166504).
For any k > 0, there are A246806(k) terms with k digits. - Rémy Sigrist, Jan 08 2023

Examples

			101 is a member since it is prime; 303 is not since it is composite and 30 is also not a prime.
		

Crossrefs

Programs

  • PARI
    is_A152242(n)=/* If n is even, the last digit must be 2 and [n\10] (if nonzero) must be in this sequence. (This check is not necessary but improves speed.) */ bittest(n,0) || return( n%10==2 && (n<10 || is_A152242(n\10))); isprime(n) && return(1); for(i=1,#Str(n)-1, n%10^i>10^(i-1) && isprime( n%10^i ) && is_A152242( n\10^i) && return(1)) \\ M. F. Hasler, Oct 15 2009; edited Oct 16 2009, to disallow leading zeros
    
  • Python
    from sympy import isprime
    def ok(n):
        if isprime(n): return True
        s = str(n)
        return any(s[i]!="0" and isprime(int(s[:i])) and ok(int(s[i:])) for i in range(1, len(s)))
    print([k for k in range(180) if ok(k)]) # Michael S. Branicky, Sep 01 2024

Extensions

More terms from M. F. Hasler and Zak Seidov, Oct 15 2009

A246807 Number of n-bit numbers that can be written as the concatenation of 0 or more prime numbers (everything written in base 2).

Original entry on oeis.org

1, 0, 2, 2, 5, 8, 15, 33, 59, 126, 246, 494, 978, 1971, 3930, 7845, 15749, 31527, 63349, 126986, 254880, 511468, 1026348, 2060633, 4135808, 8303940, 16669925, 33472231, 67201664, 134930088, 270895845, 543915707, 1091923726, 2192302476, 4400938402, 8835035284
Offset: 0

Views

Author

Jeffrey Shallit, Nov 16 2014

Keywords

Comments

Here we only consider canonical base-2 expansions (with no leading zeros). 1 is not a prime, and neither is 0.

Examples

			For n = 5 the 8 solutions counted include the primes {17,19,23,29,31} between 16 and 31, and also the numbers 21 (10.101), 22 (101.10), and 30 (111.10).
		

Crossrefs

Programs

  • Python
    from sympy import isprime, primerange
    from functools import lru_cache
    @lru_cache(maxsize=None)
    def ok(n):
      if n%4 == 0: return False
      if isprime(n): return True
      b = bin(n)[2:]
      for i in range(2, len(b)-1):
        if b[i] != '0' and isprime(int(b[:i], 2)) and ok(int(b[i:], 2)):
          return True
      return False
    def a(n):
      return 1 if n == 0 else sum(1 for m in range(2**(n-1), 2**n) if ok(m))
    print([a(n) for n in range(21)]) # Michael S. Branicky, Mar 26 2021

Extensions

More terms from Jeffrey Shallit, Nov 25 2014
a(29)-a(32) from Michael S. Branicky, Mar 26 2021
a(33)-a(35) from Jinyuan Wang, May 31 2025
Showing 1-2 of 2 results.