Substring primes
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
Primes (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...