Lucas-Lehmer test: Difference between revisions
Lucas-Lehmer test in BASIC256
Langurmonkey (talk | contribs) |
(Lucas-Lehmer test in BASIC256) |
||
Line 529:
Mersenne primes: M2 M3 M5 M7 M13 M17 M19
</pre>
=={{header|BASIC256}}==
BASIC256 has no large integer support. Calculations are limited to the range of a integer type.
<syntaxhighlight lang="basic256">print "Mersenne Primes :"
for p = 2 to 18
if lucasLehmer(p) then print "M"; p
next p
end
function lucasLehmer (p)
mp = (2 ^ p) - 1
sn = 4
for i = 2 to p-1
sn = (sn ^ 2) - 2
sn = sn - (mp * floor(sn / mp))
next
return sn = 0
end function</syntaxhighlight>
=={{header|BBC BASIC}}==
|