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
|
||||
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()
|
||||
31
Task/M-bius-function/XBasic/m-bius-function.basic
Normal file
31
Task/M-bius-function/XBasic/m-bius-function.basic
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
PROGRAM "Möbius function"
|
||||
VERSION "0.0000"
|
||||
IMPORT "xma"
|
||||
|
||||
|
||||
DECLARE FUNCTION Entry ()
|
||||
DECLARE FUNCTION mobius (n)
|
||||
|
||||
FUNCTION Entry ()
|
||||
outstr$ = " . "
|
||||
FOR i = 1 TO 200
|
||||
IF mobius(i) >= 0 THEN outstr$ = outstr$
|
||||
outstr$ = outstr$ + STR$(mobius(i)) + " "
|
||||
IF i MOD 10 = 9 THEN
|
||||
PRINT outstr$
|
||||
outstr$ = ""
|
||||
END IF
|
||||
NEXT i
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION mobius (n)
|
||||
IF n = 1 THEN RETURN 1
|
||||
FOR d = 2 TO INT(SQRT(n))
|
||||
IF n MOD d = 0 THEN
|
||||
IF n MOD (d*d) = 0 THEN RETURN 0
|
||||
RETURN -mobius(n/d)
|
||||
END IF
|
||||
NEXT d
|
||||
RETURN -1
|
||||
END FUNCTION
|
||||
END PROGRAM
|
||||
Loading…
Add table
Add a link
Reference in a new issue