Primality by trial division: Difference between revisions

Content added Content deleted
Line 2,936: Line 2,936:
=={{header|M2000 Interpreter}}==
=={{header|M2000 Interpreter}}==
<syntaxhighlight lang="m2000 interpreter">
<syntaxhighlight lang="m2000 interpreter">
Module Primality_by_trial_division {
Inventory Known1=2@, 3@
Inventory Known1=2@, 3@
IsPrime=lambda Known1 (x as decimal) -> {
IsPrime=lambda Known1 (x as decimal) -> {
=false
=false
if exist(Known1, x) then =true : exit
if exist(Known1, x) then =true : exit
Line 2,952: Line 2,953:
always
always
}
}
i=2
i=2
While Len(Known1)<20 {
While Len(Known1)<20
dummy=Isprime(i)
dummy=Isprime(i)
i++
i++
End While
}
Print "first ";len(known1);" primes"
Print "first ";len(known1);" primes"
Print Known1
Print Known1
Print "From 110 to 130"
Print "From 110 to 130"
count=0
count=0
For i=110 to 130 {
For i=110 to 130
If isPrime(i) Then Print i, : count++
If isPrime(i) Then Print i, : count++
Next
}
Print
Print
Print "Found ";count;" primes"
Print "Found ";count;" primes"
}
Primality_by_trial_division
</syntaxhighlight>
</syntaxhighlight>