Triplet of three numbers

From Rosetta Code
Revision as of 07:57, 17 May 2021 by CalmoSoft (talk | contribs) (Created page with "{{Draft task|Prime Numbers}} ;Task: Numbers n such that the three numbers n-1, n+3 and n+5 are all prime. where '''n < 6000' <br><br> =={{header|Ring}}== <lang ring> load "s...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Triplet of three numbers 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

Numbers n such that the three numbers n-1, n+3 and n+5 are all prime. where n < 6000'

Ring

<lang ring> load "stdlib.ring" see "working..." + nl see "Numbers n such that the three numbers n-1, n+3 and n+5 are all prime:" + nl row = 0

limit = 6000

for n = 2 to limit-2

   bool1 = isprime(n-1)
   bool2 = isprime(n+3)
   bool3 = isprime(n+5)
   bool = bool1 and bool2 and bool3
   if bool
      row = row + 1
      see "" + n + " "
      if row%10 = 0
         see nl
      ok    
   ok

next

see nl + "Found " + row + " primes" + nl see "done..." + nl </lang>

Output:
working...
Numbers n such that the three numbers n-1, n+3 and n+5 are all prime:
8 14 38 68 98 104 194 224 278 308 
458 614 824 854 878 1088 1298 1424 1448 1484 
1664 1694 1784 1868 1874 1994 2084 2138 2378 2684 
2708 2798 3164 3254 3458 3464 3848 4154 4514 4784 
5228 5414 5438 5648 5654 5738
Found 46 primes
done...