Numbers whose binary and ternary digit sums are prime: Difference between revisions
Numbers whose binary and ternary digit sums are prime (view source)
Revision as of 15:50, 29 August 2021
, 2 years ago→{{header|ALGOL 68}}: Use ALGOL 68-primes
(Added Fōrmulæ solution) |
(→{{header|ALGOL 68}}: Use ALGOL 68-primes) |
||
Line 6:
=={{header|ALGOL 68}}==
{{libheader|ALGOL 68-primes}}
<lang algol68>BEGIN # find numbers whose digit sums in binary and ternary are prime #
# returns the digit sum of n in base b #
PRIO DIGITSUM = 9;
Line 32 ⟶ 21:
END # DIGITSUM # ;
INT max number = 200;
PR read "primes.incl.a68" PR
[]BOOL prime =
INT n count := 0;
FOR n TO
INT d sum 2 = n DIGITSUM 2;
IF prime[ d sum 2 ] THEN
|