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.

A276707 Number of terms of A069090 with exactly n digits.

This page as a plain text file.
%I A276707 #25 Jul 03 2021 10:57:27
%S A276707 4,12,60,381,2522,19094,151286,1237792,10354144,88407746,766869330
%N A276707 Number of terms of A069090 with exactly n digits.
%H A276707 Barry Carter, <a href="https://github.com/barrycarter/bcapps/blob/master/QUORA/bc-primes.m">Mathematica work on first n for which randomly rolled digits will yield a prime</a>
%p A276707 A276707 := proc(n)
%p A276707     local a,k;
%p A276707     a := 0 ;
%p A276707     k := nextprime(10^(n-1)) ;
%p A276707     while k < 10^n do
%p A276707         if isA069090(k) then
%p A276707             a := a+1 ;
%p A276707         end if;
%p A276707         k := nextprime(k) ;
%p A276707     end do:
%p A276707     a ;
%p A276707 end proc: # _R. J. Mathar_, Dec 15 2016
%o A276707 (perl/tcsh) "bzcat A069090.b.txt.bz2  | perl -anle 'print length($F[1])' | sort | uniq -c" with https://github.com/barrycarter/bcapps/blob/master/QUORA/A069090.b.txt.bz2
%o A276707 (Python)
%o A276707 from sympy import primerange, isprime
%o A276707 def ok(p):
%o A276707     s = str(p)
%o A276707     if len(s) == 1: return True
%o A276707     return all(not isprime(int(s[:i])) for i in range(1, len(s)))
%o A276707 def a(n): return sum(ok(p) for p in primerange(10**(n-1), 10**n))
%o A276707 print([a(n) for n in range(1, 7)]) # _Michael S. Branicky_, Jul 03 2021
%o A276707 (Python) # faster version skipping bad prefixes
%o A276707 from sympy import isprime, nextprime
%o A276707 def a(n):
%o A276707     if n == 1: return 4
%o A276707     p, c = nextprime(10**(n-1)), 0
%o A276707     while p < 10**n:
%o A276707         s, fail = str(p), False
%o A276707         for i in range(1, n):
%o A276707             ti = int(s[:i])
%o A276707             if isprime(ti): fail = i; break
%o A276707         if fail: p = nextprime((ti+1)*10**(n-i))
%o A276707         else: p, c = nextprime(p), c+1
%o A276707     return c
%o A276707 print([a(n) for n in range(1, 8)]) # _Michael S. Branicky_, Jul 03 2021
%Y A276707 Cf. A069090.
%K A276707 nonn,base,more
%O A276707 1,1
%A A276707 _Barry Carter_, Sep 15 2016
%E A276707 a(9)-a(11) from _Michael S. Branicky_, Jul 03 2021