Smarandache prime-digital sequence: Difference between revisions

Content added Content deleted
(Added Swift solution)
Line 1,346: Line 1,346:
=={{header|Ring}}==
=={{header|Ring}}==
<lang ring>
<lang ring>
# Project: Calmo primes
load "stdlib.ring"
load "stdlib.ring"
limit = 25
max = 300000
num = 0
see "working..." + nl
see "wait for done..." + nl
see "First 25 Calmo primes are:" + nl
for n = 1 to max
if isprime(n)
res = calmo(n)
if res = 1
num = num + 1
if num < limit + 1
see "" + num + ". " + n + nl
ok
if num = 100
see "The hundredth Calmo prime is:" + nl
see "" + num + ". " + n + nl
exit
ok
ok
ok
next
see "done..." + nl


see "First 25 Smarandache primes:" + nl + nl
func calmo(p)

sp = string(p)
num = 0
for n = 1 to len(sp)
limit = 26
if not isprime(sp[n])
limit100 = 100
return 0
ok
for n = 1 to 34000
flag = 0
nStr = string(n)
for x = 1 to len(nStr)
nx = number(nStr[x])
if isprime(n) and isprime(nx)
flag = flag + 1
else
exit
ok
next
next
return 1
if flag = len(nStr)
num = num + 1
if num < limit
see "" + n + " "
ok
if num = limit100
see nl + nl + "100th Smarandache prime: " + n + nl
ok
ok
next
</lang>
</lang>
{{Out}}
{{Out}}
<pre>
<pre>
First 25 Smarandache primes:
working...

wait for done...
2 3 5 7 23 37 53 73 223 227 233 257 277 337 353 373 523 557 577 727 733 757 773 2237 2273
First 25 Calmo primes are:

1. 2
100th Smarandache prime: 33223
2. 3
3. 5
4. 7
5. 23
6. 37
7. 53
8. 73
9. 223
10. 227
11. 233
12. 257
13. 277
14. 337
15. 353
16. 373
17. 523
18. 557
19. 577
20. 727
21. 733
22. 757
23. 773
24. 2237
25. 2273
The hundredth Calmo prime is:
100. 33223
done...
</pre>
</pre>