Additive primes: Difference between revisions

Added uBasic/4tH version
No edit summary
(Added uBasic/4tH version)
Line 3,375:
</pre>
 
=={{header|uBasic/4tH}}==
{{trans|BASIC256}}
<lang>print "Prime", "Digit Sum"
for i = 2 to 499
if func(_isPrime(i)) then
s = func(_digSum(i))
if func(_isPrime(s)) then
print i, s
endif
endif
next
end
 
_isPrime
param (1)
local (1)
 
if a@ < 2 then return (0)
if a@ % 2 = 0 then return (a@ = 2)
if a@ % 3 = 0 then return (a@ = 3)
b@ = 5
do while (b@ * b@) < (a@ + 1)
if a@ % b@ = 0 then unloop : return (0)
b@ = b@ + 2
loop
return (1)
_digSum
param (1)
local (1)
 
b@ = 0
do while a@
b@ = b@ + (a@ % 10)
a@ = a@ / 10
loop
return (b@)</lang>
{{Out}}
<pre>Prime Digit Sum
2 2
3 3
5 5
7 7
11 2
23 5
29 11
41 5
43 7
47 11
61 7
67 13
83 11
89 17
101 2
113 5
131 5
137 11
139 13
151 7
157 13
173 11
179 17
191 11
193 13
197 17
199 19
223 7
227 11
229 13
241 7
263 11
269 17
281 11
283 13
311 5
313 7
317 11
331 7
337 13
353 11
359 17
373 13
379 19
397 19
401 5
409 13
421 7
443 11
449 17
461 11
463 13
467 17
487 19
 
0 OK, 0:176</pre>
=={{header|Vlang}}==
{{trans|go}}
374

edits