RosettaCodeData/Task/Binary-digits/Jq/binary-digits.jq
2017-09-25 22:28:19 +02:00

10 lines
236 B
Text

def binary_digits:
if . == 0 then "0"
else [recurse( if . == 0 then empty else ./2 | floor end ) % 2 | tostring]
| reverse
| .[1:] # remove the leading 0
| join("")
end ;
# The task:
(5, 50, 9000) | binary_digits