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

A276707 Number of terms of A069090 with exactly n digits.

Original entry on oeis.org

4, 12, 60, 381, 2522, 19094, 151286, 1237792, 10354144, 88407746, 766869330
Offset: 1

Views

Author

Barry Carter, Sep 15 2016

Keywords

Crossrefs

Cf. A069090.

Programs

  • Maple
    A276707 := proc(n)
        local a,k;
        a := 0 ;
        k := nextprime(10^(n-1)) ;
        while k < 10^n do
            if isA069090(k) then
                a := a+1 ;
            end if;
            k := nextprime(k) ;
        end do:
        a ;
    end proc: # R. J. Mathar, Dec 15 2016
  • Python
    from sympy import primerange, isprime
    def ok(p):
        s = str(p)
        if len(s) == 1: return True
        return all(not isprime(int(s[:i])) for i in range(1, len(s)))
    def a(n): return sum(ok(p) for p in primerange(10**(n-1), 10**n))
    print([a(n) for n in range(1, 7)]) # Michael S. Branicky, Jul 03 2021
    
  • Python
    # faster version skipping bad prefixes
    from sympy import isprime, nextprime
    def a(n):
        if n == 1: return 4
        p, c = nextprime(10**(n-1)), 0
        while p < 10**n:
            s, fail = str(p), False
            for i in range(1, n):
                ti = int(s[:i])
                if isprime(ti): fail = i; break
            if fail: p = nextprime((ti+1)*10**(n-i))
            else: p, c = nextprime(p), c+1
        return c
    print([a(n) for n in range(1, 8)]) # Michael S. Branicky, Jul 03 2021

Extensions

a(9)-a(11) from Michael S. Branicky, Jul 03 2021

A074721 Concatenate the primes as 2357111317192329313..., then insert commas from left to right so that between each pair of successive commas is a prime, always making the new prime as small as possible.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 19, 2, 3, 2, 93137414347535961677173798389971011031071091131, 2, 7, 13, 11, 3, 7, 13, 91491511, 5, 7, 163, 167, 17, 3, 17, 9181, 19, 11, 9319, 7, 19, 9211223227229233239241251257, 2, 6326927, 127, 7, 2, 81283, 2, 93307, 3, 11, 3, 13, 3, 17, 3, 3, 13, 3, 7, 3, 47, 3, 493533593673733
Offset: 1

Views

Author

Reinhard Zumkeller, Sep 04 2002

Keywords

Comments

Note that leading zeros are dropped. Example: When the primes 691, 701, 709, and 719 get concatenated and digitized, they become {..., 6, 9, 1, 7, 0, 1, 7, 0, 9, 7, 1, 9, ...}. These will end up in A074721 as: a(98)=691, a(99)=7, a(100)=17, a(101)=97, a(102)=19, ..., . Terms a(100) & a(101) have associated with them unstated leading zeros. - Hans Havermann, Jun 26 2009
Large terms in the links are probable primes only. For example, a(1290) has 24744 digits and a(4050), 32676 digits. If of course any probable primes were not actual primes, the indexing of subsequent terms would be altered. - Hans Havermann, Dec 28 2010
What is the next term after {2, 3, 5, 7, 11, 13, 17, 19}, if any, giving a(k)=A000040(k)?

Crossrefs

Programs

  • Haskell
    a074721 n = a074721_list !! (n-1)
    a074721_list = f 0 $ map toInteger a033308_list where
       f c ds'@(d:ds) | a010051'' c == 1 = c : f 0 ds'
                      | otherwise = f (10 * c + d) ds
    -- Reinhard Zumkeller, Mar 11 2014
  • Mathematica
    id = IntegerDigits@ Array[ Prime, 3000] // Flatten; lst = {}; Do[ k = 1; While[ p = FromDigits@ Take[ id, k]; !PrimeQ@p || p == 1, k++ ]; AppendTo[lst, p]; id = Drop[id, k], {n, 1289}]
  • PARI
    a=0;
    tryd(d) = { a=a*10+d; if(isprime(a),print(a);a=0); }
    try(p) = { if(p>=10,try(p\10)); tryd(p%10); }
    forprime(p=2,1000,try(p)); \\ Jack Brennen, Jun 25 2009
    

Extensions

Edited by Robert G. Wilson v, Jun 26 2009
Further edited by N. J. A. Sloane, Jun 27 2009, incorporating comments from Leroy Quet, Hans Havermann, Jack Brennen and Franklin T. Adams-Watters

A331045 a(n) is the least prime number of the form floor(n/10^k) for some k >= 0, or 0 if no such prime number exists.

Original entry on oeis.org

0, 0, 2, 3, 0, 5, 0, 7, 0, 0, 0, 11, 0, 13, 0, 0, 0, 17, 0, 19, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 41, 0, 43, 0, 0, 0, 47, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 61, 0, 0, 0, 0, 0, 67, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 83
Offset: 0

Views

Author

Rémy Sigrist, Jan 08 2020

Keywords

Comments

In other words, a(n) is the least prime prefix of n, or 0 if every prefix of n is nonprime.
This sequence is a variant of A331044.

Examples

			For n = 23:
- 2 is a prime number,
- hence a(23) = 2.
		

Crossrefs

Programs

  • PARI
    a(n, base=10) = my (d=digits(n, base), p=0); for (k=1, #d, if (isprime(p=base*p+d[k]), return (p))); return (0)

Formula

a(n) <= n with equality iff n = 0 or n belongs to A069090.
a(n) >= 0 with equality iff n belongs to A202259.
a(n) <= A331044(n).

A223458 Primes whose first digit is a composite number.

Original entry on oeis.org

41, 43, 47, 61, 67, 83, 89, 97, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881
Offset: 1

Views

Author

K. D. Bajpai, Aug 24 2013

Keywords

Examples

			409 is a prime number whose first digit is 4, a composite number, so 409 is a term.
		

Crossrefs

Cf. A069090 (primes none of whose proper initial segments are primes).

Programs

  • Maple
    KD := proc() local a,b,d,e;  a:= ithprime(n);  b:=length(a);  d:=a/(10^(b-1));  e:=floor(d); if isprime(e)=false and e>1 then RETURN (a): fi; end: seq(KD(),n=1..200);
  • Python
    from sympy import primerange
    from itertools import count, islice
    def agen(): yield from (p for e in count(1) for k in [4, 6, 8, 9] for p in primerange(k*10**e, (k+1)*10**e))
    print(list(islice(agen(), 54))) # Michael S. Branicky, Jun 25 2022

A383779 Primes where successively deleting the least significant digit yields a sequence that alternates between a prime and a nonprime at every step until a single-digit number remains.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 19, 41, 43, 47, 61, 67, 83, 89, 97, 211, 223, 227, 229, 241, 251, 257, 263, 269, 271, 277, 281, 283, 307, 331, 337, 347, 349, 353, 359, 367, 383, 389, 397, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 701, 709, 727, 743, 751, 757, 761, 769, 773, 787
Offset: 1

Views

Author

Stefano Spezia, May 09 2025

Keywords

Comments

Is this sequence infinite?
Likely no, see A383780 and comment there. - Michael S. Branicky, May 11 2025
From Michael S. Branicky, May 16 2025: (Start)
Sequence is finite with 3356513448 terms (cf. A383780).
Last term: 70123916363515199416199518301698321195339012727994799190371992151279729974757397909992327936943877127375781091143 (End)

Examples

			211 is a term since 211 is a prime, 21 is a nonprime, and 2 is a prime;
23 is not a term since 23 and 2 are both prime.
		

Crossrefs

Programs

  • Mathematica
    Unprotect[CompositeQ]; CompositeQ[1]:=True; Protect[CompositeQ]; Q[n_]:=And[AllTrue[FromDigits/@Table[Take[IntegerDigits[n], i], {i,IntegerLength[n],1,-2}], PrimeQ], AllTrue[FromDigits/@Table[Take[IntegerDigits[n], i], {i,IntegerLength[n]-1,1,-2}],CompositeQ]]; Select[Prime[Range[140]], Q]
  • Python
    from gmpy2 import is_prime, mpz
    from itertools import count, islice
    def agen():
        olst, elst = [2, 3, 5, 7], [11, 13, 17, 19, 41, 43, 47, 61, 67, 83, 89, 97]
        yield from olst + elst
        for n in count(1):
            olst2, elst2 = [], []
            for o in olst:
                for i in range(1, 100, 2):
                    t = 100*o + i
                    if is_prime(t) and not is_prime(t//10):
                        olst2.append(t)
            yield from olst2
            for e in elst:
                for i in range(100):
                    t = 100*e + i
                    if is_prime(t) and not is_prime(t//10):
                        elst2.append(t)
            yield from elst2
            olst, elst = olst2, elst2
    print(list(islice(agen(), 70))) # Michael S. Branicky, May 11 2025
    
  • Python
    # predicate test useful for large n (cf. a-file of largest terms)
    from gmpy2 import digits, is_prime, mpz
    def ok(n):
        s = digits(n)
        return is_prime(n) and all(int(is_prime(mpz(s[:-i]))) == 1-i&1 for i in range(1, len(s)))
        # Michael S. Branicky, May 16 2025

A331046 Numbers k such that floor(k/10^m) is a prime number for some m >= 0.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 43, 47, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 61, 67, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 83, 89, 97, 101, 103, 107, 109, 110, 111, 112, 113
Offset: 1

Views

Author

Rémy Sigrist, Jan 08 2020

Keywords

Comments

In other words, these are the numbers with a prime prefix.
For any m > 0:
- let f(m) be the proportion of positive numbers <= 10^m belonging to this sequence,
- we have f(m) = Sum_{p < 10^m in A069090} 1/10^A055642(p),
- also f(m) <= f(m+1) <= 1,
- so {f(m)} has a limit, say F, as m tends to infinity,
- what is the value of F?

Examples

			The number 2 is prime, so every number in A217394 belongs to this sequence.
		

Crossrefs

Cf. A055642, A069090, A202259 (complement), A217394, A331044, A331045.

Programs

  • PARI
    is(n,base=10) = while (n, if (isprime(n), return (1), n\=base)); return (0)
Showing 1-6 of 6 results.