Substring primes: Difference between revisions
Content added Content deleted
m (added that the primes are to be expressed in base 10.) |
|||
Line 3: | Line 3: | ||
;Task: |
;Task: |
||
Numbers in which all substrings are primes, where '''n < 500''' |
Numbers (in base ten) in which all substrings are primes, where '''n < 500''' |
||
<br><br> |
<br><br> |
||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
<lang ring> |
<lang ring> |
Revision as of 07:52, 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 base ten) 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...