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

Add CLU
(Add CLU)
Line 400:
121 127 129 131 133 137 143 145 151 155
157 162 167 171 173 179 181 185 191 193
199</pre>
 
=={{header|CLU}}==
<lang clu>prime = proc (n: int) returns (bool)
if n<2 then return(false) end
for i: int in int$from_to(2, n-1) do
if n//i=0 then return(false) end
end
return(true)
end prime
 
digit_sum = proc (n, base: int) returns (int)
sum: int := 0
while n>0 do
sum := sum + n//base
n := n/base
end
return(sum)
end digit_sum
 
start_up = proc ()
po: stream := stream$primary_output()
n: int := 0
for i: int in int$from_to(2, 199) do
s2: int := digit_sum(i,2)
s3: int := digit_sum(i,3)
if prime(s2) cand prime(s3) then
stream$putright(po, int$unparse(i), 4)
n := n + 1
if n // 20 = 0 then stream$putl(po, "") end
end
end
end start_up</lang>
{{out}}
<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 145 151 155 157 162 167 171 173 179 181 185 191 193
199</pre>
 
2,096

edits