1
1
Fork 0
exercism/jq/prime-factors/prime-factors.jq
Christina Sørensen 7f8baa2d63
feat(jq): prime-factor
Signed-off-by: Christina Sørensen <christina@cafkafk.com>
2024-12-18 17:21:15 +01:00

8 lines
253 B
Text

def primefactors:
if .value <= 1 then empty
elif .value < .factor * .factor then .value
elif .value % .factor > 0 then .factor += 1 | primefactors
else .factor, ((.value = .value / .factor) | primefactors)
end;
[ .factor = 2 | primefactors ]