Erdős-primes: Difference between revisions

add FreeBASIC
(Added Forth solution)
(add FreeBASIC)
Line 122:
</pre>
 
=={{header|FreeBASIC}}==
I won't bother reproducing a primality-testing function; use the one from [[Primality_by_trial_division#FreeBASIC]].
<lang freebasic>#include "isprime.bas"
 
function is_erdos_prime( p as uinteger ) as boolean
if not isprime(p) then return false
dim as uinteger kf=1, m=1
while kf < p
kf*=m : m+=1
if isprime(p - kf) then return false
wend
return true
end function
 
dim as integer c = 0, i = 1
while c<7875
i+=1
if is_erdos_prime(i) then
c+=1
if i<2500 or c=7875 then print c, i
end if
wend</lang>
{{out}}<pre>1 2
2 101
3 211
4 367
5 409
6 419
7 461
8 557
9 673
10 709
11 769
12 937
13 967
14 1009
15 1201
16 1259
17 1709
18 1831
19 1889
20 2141
21 2221
22 2309
23 2351
24 2411
25 2437
7875 999721
</pre>
=={{header|Forth}}==
{{works with|Gforth}}
781

edits