Cousin primes

From Rosetta Code
Revision as of 06:53, 18 March 2021 by CalmoSoft (talk | contribs) (Created page with "{{Draft task}} ;Task: n and n+4 are cousin primes if they are primes. <br> Show the cousin primes for 1 < n < 1000 =={{header|Ring}}== <lang ring> load "stdlib.ring" see "w...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Cousin 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 and n+4 are cousin primes if they are primes.


Show the cousin primes for 1 < n < 1000

Ring

<lang ring> load "stdlib.ring"

see "working..." + nl see "cousin primes are:" + nl

ind = 0 row = 0 limit = 1000

for n = 1 to limit

   if isprime(n) and isprime(n+4)
      row = row + 1
      see "(" + n + ", " + (n+4) + ") "
         if row%5 = 0
            see nl
         ok
   ok

next

see nl + "done..." + nl </lang>

Output:
working...
cousin primes are:
(3, 7) (7, 11) (13, 17) (19, 23) (37, 41) 
(43, 47) (67, 71) (79, 83) (97, 101) (103, 107) 
(109, 113) (127, 131) (163, 167) (193, 197) (223, 227) 
(229, 233) (277, 281) (307, 311) (313, 317) (349, 353) 
(379, 383) (397, 401) (439, 443) (457, 461) (463, 467) 
(487, 491) (499, 503) (613, 617) (643, 647) (673, 677) 
(739, 743) (757, 761) (769, 773) (823, 827) (853, 857) 
(859, 863) (877, 881) (883, 887) (907, 911) (937, 941) 
(967, 971)
done...