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.

Previous Showing 11-12 of 12 results.

A158191 Attach the smallest prime to the end of the string a(n-1) so a(n) is also prime.

Original entry on oeis.org

2, 23, 233, 2333, 23333, 2333323, 23333237, 233332373, 23333237353, 2333323735319, 2333323735319149, 2333323735319149571, 23333237353191495713, 23333237353191495713131, 233332373531914957131313
Offset: 1

Views

Author

Sergio Pimentel, Mar 13 2009

Keywords

Comments

a(279) has 1001 digits. - Michael S. Branicky, May 26 2023

Examples

			a(6) = 2333323 since a(5) = 23333 (prime) and 233333, 233335, 233337, 2333311, 2333313, 2333317 and 2333319 are all composite.
		

Crossrefs

Programs

  • Mathematica
    nxt[n_]:=Module[{k=3},While[CompositeQ[n*10^IntegerLength[k]+k],k = NextPrime[ k]];n*10^IntegerLength[k]+k]; NestList[nxt,2,20] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jul 13 2019 *)
  • Python
    from itertools import islice
    from sympy import isprime, nextprime
    def agen(): # generator of terms
        p, s = 2, "2"
        while True:
            yield p
            q = 2
            while not isprime(p:=int(s+str(q))):
                q = nextprime(q)
            s += str(q)
    print(list(islice(agen(), 15))) # Michael S. Branicky, May 26 2023

Extensions

More terms from Sean A. Irvine, Nov 29 2009

A360225 a(1) = 2, a(2) = 3, a(n) = the smallest prime whose digits consist of a(n-2), followed by zero or more digits, followed by a(n).

Original entry on oeis.org

2, 3, 23, 3023, 2393023, 3023172393023, 2393023313023172393023, 3023172393023282393023313023172393023, 239302331302317239302383023172393023282393023313023172393023
Offset: 1

Views

Author

Robert C. Lyons, Jan 30 2023

Keywords

Examples

			a(4) = 3023 because int(concat('3', '23')) is not prime, and int(concat('3', '0', '23')) is prime.
		

Crossrefs

Programs

  • Python
    from sympy import isprime
    max_n = 10
    prev_prev = 2
    prev = 3
    seq = [prev_prev, prev]
    for n in range(3, max_n+1):
        result = int(str(prev_prev) + str(prev))
        if not isprime(result):
            middle_length = 1
            keep_searching = True
            while keep_searching:
                for middle in range(0, 10**middle_length):
                    result = int(str(prev_prev) + str(middle).zfill(middle_length) + str(prev))
                    if isprime(result):
                        keep_searching = False
                        break
                middle_length = middle_length + 1
        seq.append(result)
        prev_prev = prev
        prev = result
    print(seq)
Previous Showing 11-12 of 12 results.