Primes whose sum of digits is 25: Difference between revisions

Added 11l
No edit summary
(Added 11l)
Line 12:
::: <big>(997 &nbsp; &le; &nbsp; '''n''' &nbsp; &le; &nbsp; 1,111,111,111,111,111,111,111,111). </big>
<br><br>
 
=={{header|11l}}==
{{trans|Nim}}
 
<lang 11l>F is_prime(a)
I a == 2
R 1B
I a < 2 | a % 2 == 0
R 0B
L(i) (3 .. Int(sqrt(a))).step(2)
I a % i == 0
R 0B
R 1B
 
F digit_sum(=n)
V result = 0
L n != 0
result += n % 10
n I/= 10
R result
 
V c = 0
L(n) 5000
I digit_sum(n) == 25 & is_prime(n)
c++
print(‘#4’.format(n), end' I c % 6 == 0 {"\n"} E ‘ ’)
print()
print(‘Found ’c‘ primes whose sum of digits is 25’)</lang>
 
{{out}}
<pre>
997 1699 1789 1879 1987 2689
2797 2887 3499 3697 3769 3877
3967 4597 4759 4957 4993
Found 17 primes whose sum of digits is 25
</pre>
 
=={{header|Action!}}==
1,481

edits