level 8
xxqoZXY
楼主
help
@language:simplified_chinese
质数判定
要判定a是否为质数。则输入zs(a)返回true或false.
如果a不为质数着还打印a可以至少由哪两个数相乘
如
zs(9)打印3*3=9并返回false
2也为质数?
@end
endh
function zs(z)
variable x=z,b,c,d,f
b=2
c=x/b
f=0
d=0
if x==1
return x=false
else
endif
while c>floor(c)
b=b+1
d=0
f=d+f
c=x/b
loop
while c==floor(c)
if b<x
d=1
f=d+f
else
d=0
f=d+f
endif
if f==0
return x=TRUE
else
print(c+"*"+b+"="+x+"\n")
return x=FALSE
endif
endf
2015年10月13日 13点10分
1
@language:simplified_chinese
质数判定
要判定a是否为质数。则输入zs(a)返回true或false.
如果a不为质数着还打印a可以至少由哪两个数相乘
如
zs(9)打印3*3=9并返回false
2也为质数?
@end
endh
function zs(z)
variable x=z,b,c,d,f
b=2
c=x/b
f=0
d=0
if x==1
return x=false
else
endif
while c>floor(c)
b=b+1
d=0
f=d+f
c=x/b
loop
while c==floor(c)
if b<x
d=1
f=d+f
else
d=0
f=d+f
endif
if f==0
return x=TRUE
else
print(c+"*"+b+"="+x+"\n")
return x=FALSE
endif
endf