Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. from math import sqrt; from itertools import count, islice
  2.  
  3. def isPrime(n):
  4.     return n > 0 and all(n%i for i in islice(count(2), int(sqrt(n)-1)))
  5.  
  6. def CountButSkipIfSumComposite(length=1000):
  7.     n = 0
  8.     i = 1
  9.     print(i,n)
  10.     while i < length:
  11.         i += 1
  12.         n += 1
  13.         while not isPrime(sum(map(int, str(n)))):
  14.             n += 1
  15.         print(i,n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement