Smarandache prime-digital sequence: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
No edit summary
Line 46: Line 46:
return 1
return 1
</lang>
</lang>
{{Out}}
<pre>
<pre>
working...
working...

Revision as of 09:14, 31 May 2019

Smarandache prime-digital sequence 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.

Prime p is Calmo prime if each its digit is also prime.

Task

Show first 25 Calmo primes.

Show hundrest Calmo prime.

Ring

<lang ring>

  1. Project: Calmo primes

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 hundrest Calmo prime is:" + nl
            see "" + num + ". " + n + nl
            exit
         ok
      ok
   ok

next see "done..." + nl

func calmo(p)

    sp = string(p)
    for n = 1 to len(sp)
        if not isprime(sp[n])
           return 0
        ok
    next
    return 1

</lang>

Output:
working...
wait for done...
First 25 Calmo primes are:
1. 2
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 hundrest Calmo prime is:
100. 33223
done...