Jump to content

Euclid-Mullin sequence: Difference between revisions

add FreeBASIC
(add fermat)
(add FreeBASIC)
Line 64:
od;</lang>
{{out}}<pre> 2 3 7 43 13 53 5 6221671 38709183810571 139 2801 11 17 5471 52662739 23003</pre>
 
=={{header|FreeBASIC}}==
Naive and takes forever to find the largest term, but does get there in the end.
<lang freebasic>
dim as ulongint E(0 to 15), k
dim as integer i, em
E(0) = 2 : print 2
for i=1 to 15
k=3
do
em = 1
for j as uinteger = 0 to i-1
em = (em*E(j)) mod k
next j
em = (em + 1) mod k
if em = 0 then
E(i)=k
print E(i)
exit do
end if
k = k + 2
loop
next i</lang>
 
=={{header|Julia}}==
781

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.