1. 程式人生 > >判斷一個數是否是質數的方法

判斷一個數是否是質數的方法

CLEAR
lncnt=0
lnnum=123456789098765
if (lnnum>=4 and (inlist(mod(lnnum,6),0,2,3,4))) or mod(lnnum,5)=0
    return messagebox("["+transform(lnnum)+"]不是質數")
endif
messagebox("12345")
for lnI=2 to lnnum
    if mod(lnnum,lnI)=0
        ?lnI
        lncnt=lncnt+1
        if lncnt>5
            exit
        endif
    endif
endfor
if lncnt>1
    lcstr="["+transform(lnnum)+"]不是質數"   
else
    lcstr="["+transform(lnnum)+"]是質數"   
endif
messagebox(lcstr)