Primes which contain only one odd digit

From Rosetta Code
Revision as of 08:39, 28 July 2021 by CalmoSoft (talk | contribs) (Created page with "{{Draft task}} ;Task:Primes which contain only one odd number, where '''n < 1,000''' <br><br> =={{header|Ring}}== <lang ring> load "stdlib.ring" see "working..." + nl see "...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Primes which contain only one odd digit 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
Primes which contain only one odd number, where n < 1,000



Ring

<lang ring> load "stdlib.ring" see "working..." + nl see "Primes which contain only one odd number:" + nl row = 0

for n = 1 to 1000

   odd = 0
   str = string(n)
   for m = 1 to len(str)  
       if number(str[m])%2 = 1
          odd++
       ok
   next
   if odd = 1 and isprime(n)
      see "" + n + " "
      row++
      if row%5 = 0
         see nl
      ok
   ok

next

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

Output:
working...
Primes which contain only one odd number:
3 5 7 23 29 
41 43 47 61 67 
83 89 223 227 229 
241 263 269 281 283 
401 409 421 443 449 
461 463 467 487 601 
607 641 643 647 661 
683 809 821 823 827 
829 863 881 883 887 
Found 45 prime numbers
done...