s=p=1;exec"if s%p*s%~-~p:print`p`+','+`p+2`\ns*=p*p;p+=2\n"*999
Source.
Here is an unraveling of the basic idea.
# p = 1; s = p
s=p=1
#exec"if s%p*s%~-~p:print`p`+','+`p+2`\ns*=p*p;p+=2\n"*999
for i in range(999):
# s%p = remainder of s/p
# ~p = 1s complement of p
if s%p*s%~-~p:
# `p` = repr(p)
print`p`+','+`p+2`
# s = s*p*p
s*=p*p
# p = p+2
p+=2
It calculates and prints the sets of twin prime numbers.
3,5
5,7
11,13
17,19
29,31
41,43
59,61
71,73
101,103
107,109
137,139
.....
Very cool :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With