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.

A298048 a(1) = number of 1-digit primes (that is, 4: 2,3,5,7); then a(n) = number of distinct n-digit prime numbers obtained by left- or right-concatenating a digit to the a(n-1) primes obtained in the previous iteration.

Original entry on oeis.org

4, 16, 70, 243, 638, 1450, 2819, 4951, 7629, 10677, 13267, 15182, 15923, 15796, 14369, 12547, 10291, 7939, 5703, 3911, 2559, 1595, 920, 561, 321, 167, 72, 37, 11, 6, 3
Offset: 1

Views

Author

Seiichi Manyama, Jan 11 2018

Keywords

Comments

A137812 lists the primes counted here. - Jon E. Schoenfield, Jan 28 2022

Examples

			2-digit primes:
-------------------
23   2->23 or 3->23
29   2->29
13   3->13
43   3->43
53   3->53 or 5->53
73   3->73 or 7->73
83   3->83
31   3->31
37   3->37 or 7->37
59   5->59
17   7->17
47   7->47
67   7->67
97   7->97
71   7->71
79   7->79
-------------------
a(2) = 16.
===================
3-digit primes:
[223, 233, 523, 823, 239, 229, 293, 829, 929, 113, 131, 313, 613, 137, 139, 311, 331, 431, 631, 317, 433, 443, 643, 743, 439, 353, 653, 853, 953, 173, 373, 733, 673, 773, 739, 337, 937, 379, 283, 383, 683, 883, 983, 839, 359, 593, 659, 859, 599, 617, 179, 271, 571, 971, 719, 347, 547, 647, 947, 479, 167, 367, 467, 677, 967, 197, 397, 797, 977, 997]
In the case of 223, 2->23 (adding the rightmost digit)->223 (adding the leftmost digit) and 2, 23 and 223 are prime.
In the case of 233, 2->23 (adding the rightmost digit)->233 (adding the rightmost digit) and 2, 23 and 233 are prime.
In the case of 523, 2->23 (adding the rightmost digit)->523 (adding the leftmost digit) and 2, 23 and 523 are prime.
a(3) = 70.
		

Crossrefs

Programs

  • Mathematica
    Block[{b = 10, t}, t = Select[Range[b], CoprimeQ[#, b] &]; TakeWhile[Length /@ Fold[Function[{a, n}, Append[a, Union[Join @@ {Join @@ Map[Function[k, Select[Map[Prepend[k, #] &, Range[b - 1]], PrimeQ@ FromDigits[#, b] &]], Last[a]], Join @@ Map[Function[k, Select[Map[Append[k, #] &, t], PrimeQ@ FromDigits[#, b] &]], Last[a]]}] ] ] @@ {#1, #2} &, {IntegerDigits[Prime@ Range@ PrimePi@ b, b]}, Range[2, 40]], # > 0 &]] (* Michael De Vlieger, Jan 21 2018 *)
  • Python
    from sympy import isprime
    def alst():
      primes, alst = [2, 3, 5, 7], []
      while len(primes) > 0:
        alst.append(len(primes))
        candidates = set(int(d+str(p)) for p in primes for d in "123456789")
        candidates |= set(int(str(p)+d) for p in primes for d in "1379")
        primes = [c for c in candidates if isprime(c)]
      return alst
    print(alst()) # Michael S. Branicky, Apr 11 2021
  • Ruby
    require 'prime'
    def A298048(n)
      ary = [2, 3, 5, 7]
      a_ary = [4]
      (n - 1).times{|i|
        ary1 = []
        ary.each{|a|
          (1..9).each{|d|
            j = d * 10 ** (i + 1) + a
            ary1 << j if j.prime?
            j = a * 10 + d
            ary1 << j if j.prime?
          }
        }
        ary = ary1.uniq
        a_ary << ary.size
      }
      a_ary
    end
    p A298048(10)
    

Extensions

a(16)-a(31) from Michael De Vlieger, Jan 21 2018

A297960 a(1) = number of 1-digit primes (that is, 4: 2,3,5,7); then a(n) = number of distinct n-digit prime numbers obtained by alternately right- and left-concatenating a digit to the a(n-1) primes obtained in the previous iteration.

Original entry on oeis.org

4, 9, 30, 49, 99, 74, 101, 71, 72, 35, 28, 9, 4
Offset: 1

Views

Author

Seiichi Manyama, Jan 09 2018

Keywords

Comments

No 14-digit numbers can be obtained from the four 13-digit numbers counted by a(13).

Examples

			1-digit   2-digit   3-digit    4-digit   ...  13-digit
------------------------------------------------------------
2         23        223        2237
                               2239
                    523        5231
                               5233
                               5237
                    823        8231
                               8233            6638182333331
                               8237
          29        229        2293
                               2297
                    829        8291
                               8293
                               8297
                    929        9293
3         31        131        1319
                    331        3313
                               3319
                    431
                    631        6311            5981563119937
                               6317
          37        137        1373
                    337        3371
                               3373
                    937        9371
                               9377
5         53        353        3533
                               3539
                    653
                    853        8537
                               8539
                    953        9533
                               9539
          59        359        3593
                    659        6599
                    859        8597
                               8599
7         71        271        2711
                               2713
                               2719
                    571        5711
                               5717
                    971        9719
          73        173        1733
                    373        3733
                               3739
                    673        6733            8313667333393
                               6737
                    773
          79        179
                    379        3793            2682637937713
                               3797
                    479        4793
                               4799
------------------------------------------------------------
a(1) = 4, a(2) = 9, a(3) = 30, a(4) = 49, ..., a(13) = 4.
		

Crossrefs

Programs

  • Mathematica
    Block[{b = 10, t}, t = Select[Range[b], CoprimeQ[#, b] &]; TakeWhile[Length /@ Fold[Function[{a, n}, Append[a, If[OddQ[n], Join @@ Map[Function[k, Select[Map[Prepend[k, #] &, Range[9]], PrimeQ@ FromDigits[#, b] &]], Last[a]], Join @@ Map[Function[k, Select[Map[Append[k, #] &, t], PrimeQ@ FromDigits[#, b] &]], Last[a]]]]] @@ {#1, #2} &, {IntegerDigits[Prime@ Range@ PrimePi@b, b]}, Range[2, 16]], # > 0 &]] (* Michael De Vlieger, Jan 20 2018 *)
  • Python
    from sympy import isprime
    def alst():
      primes, alst = [2, 3, 5, 7], []
      while len(primes) > 0:
        alst.append(len(primes))
        if len(alst)%2 == 0:
          candidates = set(int(d+str(p)) for p in primes for d in "123456789")
        else:
          candidates = set(int(str(p)+d) for p in primes for d in "1379")
        primes = [c for c in candidates if isprime(c)]
      return alst
    print(alst()) # Michael S. Branicky, Apr 11 2021
Showing 1-2 of 2 results.