Next special primes: Difference between revisions

From Rosetta Code
Content added Content deleted
(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...")
 
m (→‎{{header|REXX}}: added the computer programming language REXX.)
Line 3: Line 3:
;Task:n is smallest prime such that the difference of successive terms is strictly increasing.
;Task:n is smallest prime such that the difference of successive terms is strictly increasing.
<br>Let 0 < n < 1050
<br>Let 0 < n < 1050

=={{header|REXX}}==
<lang rexx></lang>


=={{header|Ring}}==
=={{header|Ring}}==

Revision as of 08:29, 26 March 2021

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

REXX

<lang rexx></lang>

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...