Primes whose first and last number is 3

From Rosetta Code
Revision as of 00:17, 24 July 2021 by CalmoSoft (talk | contribs) (Created page with "{{Draft task}} ;Task:Find primes '''n''' whose first and last number is '''3''', where '''n < 4,000''' <br><br> =={{header|Ring}}== <lang ring> load "stdlib.ring" see "work...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Primes whose first and last number is 3 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
Find primes n whose first and last number is 3, where n < 4,000



Ring

<lang ring> load "stdlib.ring" see "working..." + nl see "Primes whose first and last number is 3" + nl row = 0

for n = 1 to 4000

   strn = string(n)
   if left(strn,1) = "3" and right(strn,1) = "3" and isprime(n)
      see "" + n + " "
      row++
      if row%5 = 0
         see nl
      ok
   ok

next

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

Output:
working...
Primes whose first and last number is 1
3 313 353 373 383 
3023 3083 3163 3203 3253 
3313 3323 3343 3373 3413 
3433 3463 3533 3583 3593 
3613 3623 3643 3673 3733 
3793 3803 3823 3833 3853 
3863 3923 3943 
Found 33 numbers
done...