Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
21
Task/M-bius-function/Jq/m-bius-function-4.jq
Normal file
21
Task/M-bius-function/Jq/m-bius-function-4.jq
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
def isSquareFree:
|
||||
. as $n
|
||||
| 2
|
||||
| until ( (. * . > $n) or . == 0;
|
||||
if ($n % (.*.) == 0) then 0 # i.e. stop
|
||||
elif . > 2 then . + 2
|
||||
else . + 1
|
||||
end )
|
||||
| . != 0;
|
||||
|
||||
def mu:
|
||||
. as $n
|
||||
| if . < 1 then "Argument to mu must be a positive integer" | error
|
||||
elif . == 1 then 1
|
||||
else if isSquareFree
|
||||
then if ((prime_factors|length) % 2 == 0) then 1
|
||||
else -1
|
||||
end
|
||||
else 0
|
||||
end
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue