Summation of primes

Revision as of 08:10, 8 November 2021 by CalmoSoft (talk | contribs) (Created page with "{{Draft task}} ;Task: <br>The task descrition is taken from Project Euler (https://projecteuler.net/problem=10) <br>The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17 <br>F...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


The task descrition is taken from Project Euler (https://projecteuler.net/problem=10)
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17
Find the sum of all the primes below two million

Summation of primes is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task

Ring

<lang ring> load "stdlib.ring" see "working..." + nl sum = 0 limit = 2000000

for n = 2 to limit

   if isprime(n)
      sum += n
   ok

next

see "The sum of all the primes below two million:" + nl see "" + sum + nl see "done..." + nl </lang>

Output:
working...
The sum of all the primes below two million:
142913828922
done...