Anonymous user
Find prime numbers of the form n*n*n+2: Difference between revisions
Find prime numbers of the form n*n*n+2 (view source)
Revision as of 17:09, 15 March 2021
, 3 years ago→{{header|REXX}}: added some wording to the REXX section header.
mNo edit summary |
m (→{{header|REXX}}: added some wording to the REXX section header.) |
||
Line 195:
=={{header|REXX}}==
Since REXX doesn't have a '''isPrime''' function, this REXX program generates a number of primes such that some <br>numbers can be tested for primality directly, other numbers have to be tested by trial division for primality.
A suitable number was calculated to generate a number of primes such that about half of the computing time used to
<br>test the numbers for primality could be directly determined their primality, the other half of the computing time used
<br>would use trial division.
Since the task's requirements are pretty straight-forward and easy, a little extra code was added for presentation
<br>(title and title separator line, the count of primes found, and commatization of the numbers).
<lang rexx>/*REXX program finds and displays n primes of the form: n**3 + 2. */
parse arg LO HI hp . /*obtain optional argument from the CL.*/
Line 214 ⟶ 222:
if x//@.k==0 then iterate j
end /*k*/
finds= finds + 1 /*bump #
say right(commas(j), 20) right( commas(x), w)
end /*j*/
|