Additive primes: Difference between revisions

Content added Content deleted
(add FreeBASIC)
Line 262: Line 262:
54 additive primes found.
54 additive primes found.
</pre>
</pre>

=={{header|FreeBASIC}}==
As with the other special primes tasks, use one of the primality testing algorithms as an include.
<lang freebasic>#include "isprime.bas"

function digsum( n as uinteger ) as uinteger
dim as uinteger s
while n
s+=n mod 10
n\=10
wend
return s
end function

dim as uinteger s

print "Prime","Digit Sum"
for i as uinteger = 2 to 499
if isprime(i) then
s = digsum(i)
if isprime(s) then
print i, s
end if
end if
next i</lang>
{{out}}
<pre style="height:16em">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</pre>


=={{header|Go}}==
=={{header|Go}}==