Sum of square and cube digits of an integer are primes: Difference between revisions
Content added Content deleted
(Created page with "{{Draft task}} ;Task: <br> Sum of square and cube digits of an integer n are primes, where '''n<100''' =={{header|Ring}}== <lang ring> load "stdlib.ring" see "working..." +nl...") |
|||
Line 23: | Line 23: | ||
next |
next |
||
if isprime(sums) and isprime(sumc) |
if isprime(sums) and isprime(sumc) |
||
see "" + n + |
see "" + n + " " |
||
ok |
ok |
||
next |
next |
||
see "done..." + nl |
see nl + "done..." + nl |
||
</lang> |
</lang> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
working... |
working... |
||
16 17 25 28 34 37 47 52 64 |
|||
16 |
|||
17 |
|||
25 |
|||
28 |
|||
34 |
|||
37 |
|||
47 |
|||
52 |
|||
64 |
|||
done... |
done... |
||
</pre> |
</pre> |
Revision as of 12:19, 21 December 2021
Sum of square and cube digits of an integer are 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
Sum of square and cube digits of an integer n are primes, where n<100
Ring
<lang ring> load "stdlib.ring" see "working..." +nl
limit = 100
for n = 1 to limit
sums = 0 sumc = 0 sps = string(pow(n,2)) spc = string(pow(n,3)) for m = 1 to len(sps) sums = sums + sps[m] next for p = 1 to len(spc) sumc = sumc + spc[p] next if isprime(sums) and isprime(sumc) see "" + n + " " ok
next
see nl + "done..." + nl </lang>
- Output:
working... 16 17 25 28 34 37 47 52 64 done...