1234567891011121314151617181920212223 |
- # Find all the Russian Doll primes for a given base
- # Author: estelendur
- def isPrime(x):
- # insert primality test here
- def encase(primes):
- new = []
- app = [1, 3, 7, 9]
- for p in primes:
- for a in app:
- i = p*10+a
- if isPrime(i):
- new.append(i)
- if len(new) > 0:
- return primes + encase(new)
- else:
- return
- def dollPrimes():
- oned = [2, 3, 5, 7]
- return encase(oned)
|