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

Added 11l
(Added solution for Action!)
(Added 11l)
Line 4:
Show positive integers   '''n'''   whose binary and ternary digits sum are prime,   where   '''n   <   200'''.
<br><br>
 
=={{header|11l}}==
{{trans|Nim}}
 
<lang 11l>F is_prime(n)
I n < 2
R 0B
 
L(i) 2 .. Int(sqrt(n))
I n % i == 0
R 0B
 
R 1B
 
F digit_sum(=n, b)
V result = 0
L n != 0
result += n % b
n I/= b
R result
 
V count = 0
L(n) 2..199
I is_prime(digit_sum(n, 2)) & is_prime(digit_sum(n, 3))
count++
print(‘#3’.format(n), end' I count % 16 == 0 {"\n"} E ‘ ’)
print()
print(‘Found ’count‘ numbers.’)</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
Found 61 numbers.
</pre>
 
=={{header|Action!}}==
1,480

edits