Next special primes

From Rosetta Code
Revision as of 04:21, 26 March 2021 by CalmoSoft (talk | contribs) (Created page with "{{Draft task}} ;Task:n is smallest prime such that the difference of successive terms is strictly increasing. <br>Let 0 < n < 1050 =={{header|Ring}}== <lang ring> load "stdl...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Next special 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
n is smallest prime such that the difference of successive terms is strictly increasing.


Let 0 < n < 1050

Ring

<lang ring> load "stdlib.ring"

see "working..." + nl

row = 0 num = null limit1 = 100 nextPrime = 2 oldPrime = 2

for n = 1 to limit1

   nextPrime = oldPrime + n
   if isprime(nextPrime)
      row = row + 1
      see "" + nextPrime + " "
      if (row%5) = 0
          see nl
      ok
      oldPrime = nextPrime
   ok

next

see nl + "done..." + nl

</lang>

Output:
working...
3 5 11 19 29 
41 59 79 101 127 
157 191 227 269 313 
359 409 461 521 587 
659 733 809 887 967 
1049 
done...