Summation of primes: Difference between revisions
Content added Content deleted
(Summation of primes en Python) |
|||
Line 324: | Line 324: | ||
The sum of primes below 2 million is 142,913,828,922 |
The sum of primes below 2 million is 142,913,828,922 |
||
</pre> |
</pre> |
||
=={{header|Python}}== |
|||
<lang python>#!/usr/bin/python |
|||
def isPrime(n): |
|||
for i in range(2, int(n**0.5) + 1): |
|||
if n % i == 0: |
|||
return False |
|||
return True |
|||
if __name__ == '__main__': |
|||
suma = 2 |
|||
n = 1 |
|||
for i in range(3, 2000000, 2): |
|||
if isPrime(i): |
|||
suma += i |
|||
n+=1 |
|||
print(suma</lang> |
|||
{{out}} |
|||
<pre>142913828922</pre> |
|||
=={{header|Raku}}== |
=={{header|Raku}}== |