Substring primes: Difference between revisions
Content added Content deleted
(Created page with "{{Draft task}} Category:Prime Numbers ;Task: Numbers in which all substrings are primes, where '''n < 500''' <br><br> =={{header|Ring}}== <lang ring> load "stdlib.ring"...") |
|||
Line 31: | Line 31: | ||
next |
next |
||
next |
next |
||
if flag = 0 |
|||
ok |
|||
if flag = 1 |
if flag = 1 |
||
see "" + n + " " |
see "" + n + " " |
Revision as of 07:16, 5 April 2021
Substring 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
Numbers in which all substrings are primes, where n < 500
Ring
<lang ring> load "stdlib.ring"
see "working..." + nl see "Numbers in which all substrings are primes:" + nl
row = 0 limit1 = 500
for n = 1 to limit1
flag = 1 strn = string(n) for m = 1 to len(strn) for p = 1 to len(strn) temp = substr(strn,m,p) if temp != "" if isprime(number(temp)) flag = 1 else flag = 0 exit 2 ok ok next next if flag = 1 see "" + n + " " ok
next
see nl + "Found " + row + " numbers in which all substrings are primes" + nl see "done..." + nl </lang>
- Output:
working... Numbers in which all substrings are primes: 2 3 5 7 23 37 53 73 373 Found 9 numbers in which all substrings are primes done...