Data update
This commit is contained in:
parent
29a5eea0d4
commit
5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions
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