Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,30 @@
|
|||
Module CheckIt {
|
||||
Function IsPrime (x) {
|
||||
if x<=5 OR frac(x) then {
|
||||
if x = 2 OR x = 3 OR x = 5 then =true
|
||||
Break
|
||||
}
|
||||
if x mod 2 else exit
|
||||
if x mod 3 else exit
|
||||
x1=sqrt(x): d=5@
|
||||
{if x mod d else exit
|
||||
d += 2@: if d>x1 then =true : exit
|
||||
if x mod d else exit
|
||||
d += 4@: if d<= x1 else =true: exit
|
||||
loop
|
||||
}
|
||||
}
|
||||
\\ For Next loops or For {} loops can't change iterator variable (variable has a copy of real iterator)
|
||||
\\ In those loops we have to use Continue to skip lines and repeat the loop.
|
||||
\\ so we have to use Block iterator, using Loop which set a flag current block to repeat itself once.
|
||||
def long Limit=42, n
|
||||
def decimal i
|
||||
i=Limit
|
||||
{
|
||||
if n<Limit Else exit
|
||||
if isPrime(i) then n++ : Print format$("n={0::2}: {1:-20}", n, str$(i,"#,###")) : i+=i-1
|
||||
i++
|
||||
loop
|
||||
}
|
||||
}
|
||||
CheckIt
|
||||
Loading…
Add table
Add a link
Reference in a new issue