Data update
This commit is contained in:
parent
29a5eea0d4
commit
5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions
27
Task/M-bius-function/Gambas/m-bius-function.gambas
Normal file
27
Task/M-bius-function/Gambas/m-bius-function.gambas
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
Public Sub Main()
|
||||
|
||||
Dim outstr As String = " . "
|
||||
|
||||
For i As Integer = 1 To 200
|
||||
If mobius(i) >= 0 Then outstr &= " "
|
||||
outstr &= Str(mobius(i)) & " "
|
||||
If i Mod 10 = 9 Then
|
||||
Print outstr
|
||||
outstr = ""
|
||||
End If
|
||||
Next
|
||||
|
||||
End
|
||||
|
||||
Function mobius(n As Integer) As Integer
|
||||
|
||||
If n = 1 Then Return 1
|
||||
For d As Integer = 2 To Int(Sqr(n))
|
||||
If n Mod d = 0 Then
|
||||
If n Mod (d * d) = 0 Then Return 0
|
||||
Return -mobius(n / d)
|
||||
End If
|
||||
Next
|
||||
Return -1
|
||||
|
||||
End Function
|
||||
Loading…
Add table
Add a link
Reference in a new issue