Primes whose sum of digits is 25: Difference between revisions
Content added Content deleted
(Added solution for Action!) |
|||
Line 12: | Line 12: | ||
::: <big>(997 ≤ '''n''' ≤ 1,111,111,111,111,111,111,111,111). </big> |
::: <big>(997 ≤ '''n''' ≤ 1,111,111,111,111,111,111,111,111). </big> |
||
<br><br> |
<br><br> |
||
=={{header|Action!}}== |
|||
{{libheader|Action! Sieve of Eratosthenes}} |
|||
<lang Action!>INCLUDE "H6:SIEVE.ACT" |
|||
BYTE FUNC SumOfDigits(INT x) |
|||
BYTE s,d |
|||
s=0 |
|||
WHILE x#0 |
|||
DO |
|||
d=x MOD 10 |
|||
s==+d |
|||
x==/10 |
|||
OD |
|||
RETURN (s) |
|||
PROC Main() |
|||
DEFINE MAX="4999" |
|||
BYTE ARRAY primes(MAX+1) |
|||
INT i,count=[0] |
|||
Put(125) PutE() ;clear the screen |
|||
Sieve(primes,MAX+1) |
|||
FOR i=2 TO MAX |
|||
DO |
|||
IF primes(i)=1 AND SumOfDigits(i)=25 THEN |
|||
PrintI(i) Put(32) |
|||
count==+1 |
|||
FI |
|||
OD |
|||
PrintF("%E%EThere are %I primes",count) |
|||
RETURN</lang> |
|||
{{out}} |
|||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Primes_which_sum_of_digits_is_25.png Screenshot from Atari 8-bit computer] |
|||
<pre> |
|||
997 1699 1789 1879 1987 2689 2797 2887 3499 3697 3769 3877 3967 4597 4759 4957 4993 |
|||
There are 17 primes |
|||
</pre> |
|||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |