Jump to content

Binary digits: Difference between revisions

m (beads indenting)
(→‎{{header|jq}}: modernize)
Line 2,467:
=={{header|jq}}==
<lang jq>def binary_digits:
[ recurse( ./2 | floor; . > 0) % 2 ] | reverse | join("") ;
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:
2,502

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.