OFFSET
1,1
COMMENTS
Prime digits are 2, 3, 5 or 7. Nonprime digits are 0, 1, 4, 6, 8 or 9.
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
EXAMPLE
13 (1=nonprime, 3=prime) = a(1).
MAPLE
A109066c := proc(n) nops(convert(n, base, 10))-A109066(n) ; end:
A109066 := proc(n) local dgs, a ; dgs := convert(n, base, 10) ; a := 0 ; for i in dgs do if isprime(i) then a := a+1 ; fi; od: a ; end:
for i from 1 to 400 do p := ithprime(i) ; if A109066(p) = A109066c(p) then printf("%d, ", p) ; fi; od: # R. J. Mathar, Feb 09 2009
MATHEMATICA
Select[Prime[Range[5, 300]], Length[Select[IntegerDigits[#], PrimeQ]]==Length[ Select[ IntegerDigits[ #], !PrimeQ[ #]&]]&] (* Harvey P. Dale, Dec 15 2022 *)
PROG
(Python)
from sympy import isprime
def ok(n):
if not isprime(n): return False
s, counts = str(n), [0, 0]
for c in s: counts[int(c in "2357")] += 1
return counts[0] == counts[1]
print([k for k in range(10**4) if ok(k)]) # Michael S. Branicky, Apr 23 2024
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Juri-Stepan Gerasimov, Feb 08 2009
STATUS
approved