Data update
This commit is contained in:
parent
29a5eea0d4
commit
5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions
30
Task/M-bius-function/PureBasic/m-bius-function.basic
Normal file
30
Task/M-bius-function/PureBasic/m-bius-function.basic
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
Procedure.i mobius(n)
|
||||
If n = 1:
|
||||
ProcedureReturn 1
|
||||
EndIf
|
||||
For d = 2 To Int(Sqr(n))
|
||||
If Mod(n, d) = 0:
|
||||
If Mod(n, d * d) = 0:
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
ProcedureReturn -mobius(n / d)
|
||||
EndIf
|
||||
Next d
|
||||
ProcedureReturn -1
|
||||
EndProcedure
|
||||
|
||||
OpenConsole()
|
||||
outstr$ = " . "
|
||||
For i = 1 To 200
|
||||
If mobius(i) >= 0:
|
||||
outstr$ = outstr$ + " "
|
||||
EndIf
|
||||
outstr$ = outstr$ + Str(mobius(i)) + " "
|
||||
If Mod(i, 10) = 9:
|
||||
PrintN(outstr$)
|
||||
outstr$ = ""
|
||||
EndIf
|
||||
Next i
|
||||
|
||||
PrintN(#CRLF$ + "Press ENTER to exit"): Input()
|
||||
CloseConsole()
|
||||
Loading…
Add table
Add a link
Reference in a new issue