RosettaCodeData/Task/Mertens-function/PureBasic/mertens-function.basic

15 lines
411 B
Plaintext

Dim M.i(1000)
M(1)=1
For n=2 To 1000
psum=0
For k=2 To n : psum+M(Int(n/k)) : Next : M(n)=1-psum
If M(n)=0 : z+1 : If M(n-1)<>0 : c+1 : EndIf : EndIf
Next
OpenConsole("")
PrintN("First 99 Mertens numbers:") : Print(Space(4))
For n=1 To 99 : Print(RSet(Str(M(n)),4)) : If n%10=9 : PrintN("") : EndIf : Next
PrintN("M(N) is zero "+Str(z)+" times.") : PrintN("M(N) crosses zero "+Str(c)+" times.")
Input()