Numbers with prime digits whose sum is 13: Difference between revisions

m (added highlighting.)
Line 981:
2722 3235 3253 3325 3352 3523 3532 5233 5323 5332 7222
22225 22252 22333 22522 23233 23323 23332 25222 32233 32323 32332
33223 33232 33322 52222 222223 222232 222322 223222 232222 322222 </pre>
 
=={{header|Lua}}==
{{trans|C}}
<lang lua>function prime_digits_sum_13(n)
local sum = 0
while n > 0 do
local r = n % 10
if r ~= 2 and r ~= 3 and r ~= 5 and r ~= 7 then
return false
end
n = math.floor(n / 10)
sum = sum + r
end
return sum == 13
end
 
local c = 0
for i=1,999999 do
if prime_digits_sum_13(i) then
io.write(string.format("%6d ", i))
if c == 10 then
c = 0
print()
else
c = c + 1
end
end
end
print()</lang>
{{out}}
<pre> 337 355 373 535 553 733 2227 2272 2335 2353 2533
2722 3235 3253 3325 3352 3523 3532 5233 5323 5332 7222
22225 22252 22333 22522 23233 23323 23332 25222 32233 32323 32332
33223 33232 33322 52222 222223 222232 222322 223222 232222 322222 </pre>
 
1,452

edits