ke1dan

Untitled

Jul 10th, 2020
622
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. from itertools import product as p
  2.  
  3. def is_prime(n):
  4.     d = 2
  5.     while d * d <= n and n % d != 0:
  6.         d += 1
  7.     return d * d > n
  8.  
  9. def get_total_primes(a, b):
  10.     c=0
  11.     for j in range(len(str(a)),len(str(b))+1):
  12.         for i in p('2357',repeat = j):
  13.             q = int(''.join(i))
  14.             if a<=q<b and is_prime(q):
  15.                 c+=1
  16.     return c
Advertisement
Add Comment
Please, Sign In to add comment