User:Yeti: Difference between revisions
Content added Content deleted
Line 57: | Line 57: | ||
n += 1</lang> |
n += 1</lang> |
||
{{out}} |
|||
<pre> |
|||
2 |
|||
3 |
|||
5 |
|||
7 |
|||
11 |
|||
13 |
|||
17 |
|||
19 |
|||
23 |
|||
29 |
|||
</pre> |
|||
...the program has to be terminated by the user e.g. by typing ctrl-c. |
|||
=Python/Primes/FSOE3= |
|||
{{works with|Python|2.x}} |
|||
<lang python> |
|||
L = {} |
|||
n = 2 |
|||
while 1: |
|||
if n in L: |
|||
P = L[n] |
|||
else: |
|||
P = n |
|||
print n |
|||
m = n+P |
|||
while m in L: |
|||
m += P |
|||
L[m] = P |
|||
n += 1</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |