Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/Prime-decomposition/Jq/prime-decomposition-1.jq
Normal file
14
Task/Prime-decomposition/Jq/prime-decomposition-1.jq
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
def factors:
|
||||
. as $in
|
||||
| [2, $in, false]
|
||||
| recurse(
|
||||
. as [$p, $q, $valid, $s]
|
||||
| if $q == 1 then empty
|
||||
elif $q % $p == 0 then [$p, $q/$p, true]
|
||||
elif $p == 2 then [3, $q, false, $s]
|
||||
else ($s // ($q | sqrt)) as $s
|
||||
| if $p + 2 <= $s then [$p + 2, $q, false, $s]
|
||||
else [$q, 1, true]
|
||||
end
|
||||
end )
|
||||
| if .[2] then .[0] else empty end ;
|
||||
9
Task/Prime-decomposition/Jq/prime-decomposition-2.jq
Normal file
9
Task/Prime-decomposition/Jq/prime-decomposition-2.jq
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
24 | factors
|
||||
#=> 2 2 2 3
|
||||
|
||||
[9007199254740992 | factors] | length
|
||||
#=> 53
|
||||
|
||||
# 2**29-1 is 536870911
|
||||
[ 536870911 | factors ]
|
||||
#=> [233,1103,2089]
|
||||
Loading…
Add table
Add a link
Reference in a new issue