Numbers with prime digits whose sum is 13
Find all the numbers vhich digits are primes and sum of them is 13.
Numbers with prime digits whose sum is 13 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.
Ring
<lang ring> load "stdlib.ring"
sum = 0 limit = 10000 aPrimes = []
for n = 1 to limit
sum = 0 st = string(n) for m = 1 to len(st) num = number(st[m]) if isprime(num) sum = sum + num flag = 1 else flag = 0 exit ok next if flag = 1 and sum = 13 add(aPrimes,n) ok
next
see "Unlucky numbers are:" + nl see showArray(aPrimes)
func showarray vect
svect = "" for n in vect svect += "" + n + "," next ? "[" + left(svect, len(svect) - 1) + "]"
</lang>
- Output:
Unlucky numbers are: [337,355,373,535,553,733,2227,2272,2335,2353,2533,2722,3235,3253,3325,3352,3523,3532,5233,5323,5332,7222]