Numbers whose binary and ternary digit sums are prime: Difference between revisions

Added solution for Action!
(add tinybasic)
(Added solution for Action!)
Line 4:
Show positive integers   '''n'''   whose binary and ternary digits sum are prime,   where   '''n   <   200'''.
<br><br>
 
=={{header|Action!}}==
{{libheader|Action! Sieve of Eratosthenes}}
<lang Action!>INCLUDE "H6:SIEVE.ACT"
 
BYTE Func IsPrime(INT i BYTE base BYTE ARRAY primes)
BYTE sum,d
 
sum=0
WHILE i#0
DO
d=i MOD base
sum==+d
i==/base
OD
RETURN (primes(sum))
 
PROC Main()
DEFINE MAX="199"
BYTE ARRAY primes(MAX+1)
INT i,count=[0]
 
Put(125) PutE() ;clear the screen
Sieve(primes,MAX+1)
FOR i=1 TO MAX
DO
IF IsPrime(i,2,primes)=1 AND IsPrime(i,3,primes)=1 THEN
PrintI(i) Put(32)
count==+1
FI
OD
PrintF("%E%EThere are %I numbers",count)
RETURN</lang>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Numbers_which_binary_and_ternary_digit_sum_are_prime.png Screenshot from Atari 8-bit computer]
<pre>
5 6 7 10 11 12 13 17 18 19 21 25 28 31 33 35 36 37 41 47 49 55 59 61 65 67 69 73 79 82 84 87 91 93 97
103 107 109 115 117 121 127 129 131 133 137 143 14 5 151 155 157 162 167 171 173 179 181 185 191 193 199
 
There are 61 numbers
</pre>
 
=={{header|ALGOL 68}}==
Anonymous user