g | x | w | all
Bytes Lang Time Link
021JavaScript230228T001121Znoodle p
036Casio BASIC fx9750giii240910T133256Zmadeforl
036TIBASIC240918T195535Zabsolute
002Uiua240208T070826ZAdelie
114Acc!!240420T051741ZDLosc
072YASEPL240207T135545Zmadeforl
028Swift230723T231403ZmacOSist
014*><>240215T143757ZBee H.
029Labyrinth240214T073738ZBubbler
013Perl 5240207T150227ZXcali
001Japt230227T154049Znoodle p
025ForWhile230724T170736Zbsoelch
013Zsh230724T135744Zroblogic
027Befunge93230614T230429ZTotallyJ
001Thunno 2230614T172106ZThe Thon
001vemf230402T041139Z
040BrainFlak230402T034225ZWheat Wi
008Raku230313T020448ZMark Ree
068Scratch230227T235124Znoodle p
355Minecraft Data Pack via Lectern230312T180919ZCommand
026Prolog SWI230228T072946ZAiden Ch
nanPiet + asciipiet230307T065747ZBubbler
002J230303T180526ZRichard
029Knight v2230303T091958ZAiden Ch
nanPiet + asciipiet230228T021541ZAiden Ch
017Simply230301T205438ZIsmael M
002CJam230301T201510Zemirps
009R230301T131501Zpajonk
001Jelly230301T045958ZAiden Ch
025Alice230301T034240ZJulian
020Swift230227T222455Zuser1171
070SNOBOL4 CSNOBOL4230301T023405ZGiuseppe
003Charcoal230227T084053ZNeil
037Pure Bash no external utilities230227T182851ZDigital
062Haskell230228T215358ZDLosc
078Quipu230228T202408ZDLosc
nanPiet + asciipiet230227T145027ZParcly T
001APLDyalog Extended230228T080244ZAiden Ch
006PARI/GP230228T100719Zalephalp
001flax230228T095959Zzoomlogo
006PHP230228T095203ZKaddath
031Haskell230228T093923ZAiden Ch
023GeoGebra230228T073441ZAiden Ch
028Befunge93 PyFunge230228T053621Zyeah ok
050Desmos230228T000727ZAiden Ch
002J230227T230426Zsouth
003Pip230227T204744Zjezza_99
016Scala230227T202116Zwaf9000
011Excel230227T195019ZEngineer
004dc230227T173851ZDigital
003Julia 0.7230227T151304ZKirill L
001MATL230227T150358ZSuever
008Ruby n230227T150248ZKirill L
024C# .NET Core230227T140145ZTvde1
054Python 2230227T113132ZElPedro
015Arturo230227T132823Zchunes
004Factor230227T132543Zchunes
015Risky230227T124212Zxigoi
045Nim230227T124943Zxigoi
015Nibbles230227T123827Zxigoi
001Pyt230227T112610ZKip the
023Retina 0.8.2230227T100149ZNeil
001Brachylog230227T095256ZFatalize
070Whitespace230227T082857ZKevin Cr
018Wolfram Language Mathematica230227T083011ZZaMoC
132BrainFlak230227T073139ZRaviRavi
018Java 8230227T075601ZKevin Cr
001MathGolf230227T075329ZKevin Cr
021C GCC230227T074854Zbadatgol
014bc230227T055628Zcocomac
00105AB1E230227T072004ZThe Thon
001Vyxal230227T071706ZThe Thon
nan230227T071536ZThe Thon
002K ngn/k230227T071456Zdoug
013Python230227T063208Zloopy wa
017Python230227T055451ZParcly T
016JavaScript230227T053440ZUnmitiga
019Python 3230227T044952ZSectorCo

JavaScript, 21 bytes

f=n=>n?f(n>>1)+n%2:""

Try it online!

Not quite as short as the builtin but wanted to get a short solution doing it more manually. This solution recursively divides n by 2 and prepends the remainder.

Explanation:

f = n =>          // define f with arg n
  n               // is n nonzero?
   ?              // yes ->
     f(           //   recurse with
       n >> 1     //     equivalent to floor dividing by 2
     ) + n % 2    //   append remainder (0 or 1)
   : ""           // no -> empty string is prepended to coerce everything

Figured this out from reading wikiHow to convert decimal to binary lol

Casio BASIC (fx-9750giii), 40 38 36 bytes

(this is a translation of absoluteAquarian's answer in TI-BASIC. rock on, you're cool!)

?→A
2^-Seq(X,X,Int (ln A÷ln 2),0,-1)A
MOD(Intg List Ans,2

asks you for a number, then prints it out as binary in the form of a list.

Casio BASIC (fx-9750giii), 6 bytes(?)

this requires the calculator to be in decimal mode and it has to be typed in mathprint.

?→A:A▶Bin

TI-BASIC, 36 bytes

Prompt A
iPart(ln(A+.5)/ln(2
2fPart(.5int(A2^(cumSum(binomcdf(Ans,0))-Ans-1

A modified/fixed version of a routine on the wiki (1) to support only base 2.

Explanation:

Prompt A                         ; Request the number
                                 ;       A = 18
iPart(ln(A+.5)/ln(2              ; Get how many digits the number has in binary - 1
                                 ;     Ans = 4
   cumSum(binomcdf(Ans,0))-Ans-1 ; Make a list from -Ans to 0
                                 ;         = [ -4, -3, -2, -1, 0 ]
  2^                             ; Convert to powers of 2
                                 ;         = [ .0625, .125, .25, .5, 0 ]
 int(A                           ; Convert to even and odd numbers
                                 ;         = [ 1, 2, 4, 9, 18 ]
2fPart(.5                        ; Convert to modulus 2
                                 ;     Ans = [ 1, 0, 0, 1, 0 ]
                                 ; Implicit print of Ans

Examples:

prgmCDGF2C
A=?15
       {1 1 1 1}
prgmCDGF2C
A=?16
     {1 0 0 0 0}
prgmCDGF2C
A=?18
     {1 0 0 1 0}

Note: TI-BASIC is a tokenized language. Character count does not equal byte count.
Program size is equal to \$MEM\: byte\: count - program\: name\: length - 9\: bytes\$.

Uiua, 9 2 bytes

-7 bytes since the challenge doesn't disallow functions

⇌⋯

Returns an array of bits. Try it online!

Explanation

 ⋯ # encode number as bit array, LSB-first
⇌  # reverse array

Acc!!, 114 bytes

Count i while _%11-10 {
_*10+_%11+N%48
}
_/11
Count d while 1 {
Count i while 1/(_/2^d) {
Write 48+_/2^(d-i)%2
}
}

Outputs nothing when the input is 0. Exits with an error. Try it online!

Explanation

# Read a decimal integer
# We'll store the value in _/11 and the most recently read digit (or 10 for newline)
# in _%11
# Loop until the most recently read character was a newline
Count i while _%11-10 {
  # (_-_%11)*10   Multiply the value by 10
  # +(_%11)*11    Add the most recent digit to the value
  # +N%48         Read the next digit or newline
  # This gives          (_-_%11)*10+(_%11)*11+N%48
  # which simplifies to _*10-(_%11)*10+(_%11)*11+N%48
  # which simplifies to...
  _*10+_%11+N%48
}
# Store the value in the accumulator directly
_/11
# Write the accumulator value as base 2
# Figure out how many bits the accumulator value has
Count d while 1 {
  # The i loop only runs once 2^d is the same bit length as the accumulator
  # value, at which point it outputs all the bits and then throws an error,
  # ending the program
  # This happens when _/2^d is 1, i.e. 1/(_/2^d) is not zero
  # If the accumulator value is 0, the loop condition instead throws a division-by-zero
  # error, ending the program with no output
  Count i while 1/(_/2^d) {
    # Output each bit from most significant to least significant
    Write 48+_/2^(d-i)%2
    # When d-i becomes negative, the expression is a float, and Write throws
    # an error because Python's chr() doesn't accept a float argument
  }
}

If outputting little-endian is allowed, we can get this down to 80 bytes:

Count i while _%11-10 {
_*10+_%11+N%48
}
_/11
Count d while _ {
Write 48+_%2
_/2

Try it online!

YASEPL, 76 72 bytes

=d'(=1)""`9!m$d%!1ſm!d/(}7,0,9=o-!h)""!u®1-=k$u`8!m¥u,1!hſm!u-}1,o,8>h

YASEPL is a (horribly coded and just stupid in general) esolang I made a while ago in Node.JS. it gets input via a prompt and STDIN. heres the output:

a picture containing the output of the code I just put.

Swift, 35 28 bytes

let b={String($0+0,radix:2)}

*><>, 14 bytes

Input is passed in through the -i flag.

:2%:n-2,:0)?!;
:               Duplicate the value on the stack
 2              Push 2 onto the stack
  %             Modulo those two
   :            Duplicate the result
    n           Pop and print that duplicate
     -          Subtract the result from our original number
      2         Push 2
       ,        Divide the two
        :       Duplicate that result
         0      Push 0
          )?!;  If the dividend is greater than 0, loop again

Try it online!

Labyrinth, 29 bytes

?
~:"" 2%!@
 _ ( _ "
 2/);(""

Try it online!

Handling zero input is nontrivial since loops in Labyrinth require a nonzero value at entry. To remedy this, the code uses bitwise NOT of the input value and repeatedly divides it by 2, which is floor division and therefore equivalent to arithmetic right shift. The loop is exited when the top reaches -1, and it runs at least once to ensure that the second loop is also entered with a nonzero value. As a result, the input of 0 outputs 0.

Entry   ?~
?       Take input  [n]
~       Bitwise NOT [~n]

Loop 1  :_2/)(  [~n ~n/2 .. ~n/2^i] -> [~n .. ~n/2^(i+1)]
:_2/    Copy and divide by 2
)       Test if the top is -1; exit if so
(       Revert the value to continue the loop

Path    ;  [~n ~n/2 .. ~n/2^i 0] -> [~n ~n/2 .. ~n/2^i]
;       Drop the unnecessary zero

Loop 2  (_2%!  [~n ~n/2 .. ~n/2^i] -> [~n .. ~n/2^(i-1)]
(       Invert the parity of the top
        (decrement is chosen to ensure the top is nonzero)
_2%!    Mod 2 and print
        Exit the loop if there is nothing more to print

End     @
@       Halt

Perl 5, 13 bytes

printf"%b",<>

Try it online!

Japt, 1 byte

¤

Try it

Shortcut for s2 which converts a number to a string in base 2

ForWhile, 25 bytes

{:[:1&'2/0@1+0$:)@[48+#)}

Takes argument from the stack and prints to console

online interpreter

Explanation

{                       }  \ anonymous procedure
 :[                        \ repeat n times
   :1&                     \ push the lowest bit of n
      '2/                  \ divide n by 2
         0@1+0$            \ increment memory cell 0
               :)          \ break loop if n is zero
                 @         \ read memory at address 0 (n is still on stack)
                  [48+#)   \ print bits converted to characters 

Zsh, 13 bytes

<<<$[[##2]$1]

Try it online!

Vanilla answer... here are a couple more interesting variants

Befunge-93, 27 Bytes

v
2:._@#<-
&
<_!#: ^#/2\%2:

Try it online!

Alternately the following works as long as 0/0 results in a non-zero value pushed onto the stack (this is an option of PyFunge and the default behavior of this compiler online

v
2:._@#<-
&
<_  :/^#2\%2:

This results in only needing 26 bytes

This is my first post and so if anyone has comments of how I can improve this post feel free to let me know

Thunno 2, 1 byte

Attempt This Online!

vemf, 1 byte

é

Represents α as a 64-element list of bits.

Brain-Flak, 40 bytes

{(<>)<>({<({}[()])><>[(()[{}])]()<>})}<>

Try it online!

The other Brain-flak answer looked very long.

Explanation

The first thing we can notice is that the following snippet:

(()[{}])

does something very nice. It's equivalent to 1-x, which when constrained to the inputs of 0 and 1 will give us an increment and mod 2 operation. So we can calculate the mod 2 of a number by just repeating this snippet that many times starting with 0.

{({}[()])<>(()[{}])<>}

This is nice and it can be modified to give us the full divmod. Each cycle we add the value of the accumulator we are building. Since it is 1 half the time and 0 the other half this gives us half the value. The one issue is it rounds up instead of down, so instead of adding n each step we add 1-n. That is we add 1 when the accumulator is 0 and 0 when the accumulator is 1.

({<({}[()])><>[(()[{}])]()<>})

Now we add a bit of code to add a new accumulator each step and we can just repeat this divmod process until the div is zero.

{(<>)<>({<({}[()])><>[(()[{}])]()<>})}<>

Raku, 8 bytes

.base(2)

Try it online!

The above version operates on the current topic, as seen in the demo code. To make it a function accepting an argument, just wrap it in curly braces for another two bytes.

Scratch, 70 68 bytes

Puts a list of binary digits onto the a global variable, which is automatically displayed when the program finishes execution.

Saved 2 bytes by using ([floor v]of((n)/(2 instead of ((n)-(((n)mod(2))/(2

Scratchblocks syntax:

define a(n
if<(n)>(0)>then
a([floor v]of((n)/(2
add((n)mod(2))to[a v

Try it on Scratch

Minecraft Data Pack via Lectern, 355 bytes

@function a:b
data modify storage  b set value []
scoreboard players set  i 2
function a:c
@function a:c
scoreboard players operation a i = i i
data modify storage  b prepend value 0
execute store result storage  b[0] int 1 run scoreboard players operation a i %=  i
scoreboard players operation i i /=  i
execute if score i i matches 1.. run function a:c

The function is a:b.

Takes input in the fake player i and the objective i (Which can be set using /scoreboard objectives add i dummy, /scoreboard players set i i <input number>).

Outputs a list via data storage : b (Which can be read by /data get storage : b).

I'm not sure this I/O format is valid, but this would be the standard way to do that if you were writing a library, although with the objective created by the data pack (and, of course, with more meaningful names).

Prolog (SWI), 26 bytes

:-read(X),format("~2r",X).

Try it online!

With builtin.

Prolog (SWI), 42 36 35 bytes

-6 bytes thanks to @Steffan

-1 byte thanks to @false

N+X:-N<1,X=0;N//2+B,X is N/\1+10*B.

Try it online!

Without builtin.


Man, I haven't golfed in Prolog in a while; I forgot how wonky it is to code in it lol. Please tell me if there are any more golfs!

Piet + ascii-piet, 29 bytes (6×9=54 codels)

tkvuumf_iliqqdltT QqKln?_sf ?

Try Piet online!

B2C2 is I (no-op). The printing loop is now:

O d 1 % D I

which nicely forms a color loop.


Piet + ascii-piet, 33 bytes (5×9=45 codels)

tkvuumf_iliqqdltT _?tser?_iqtf? ?

Try Piet online!

The bit-extracting logic is the same as Parcly Taxel's. The printing logic is new.

Loop 1: push bits of the input (A1 -> A8 -> B8 -> B1 -> A1)

D           No-op
I           Take input (n); no-op afterwards
d 2 %       [...bits n n%2]
2 1 r 2 /   [...bits n%2 n/2]
d ! D       Turn right if the new n is 0

Now there is a leading zero, which is handled nicely by A2->B2 (>). Since the number below is 0 or 1, and 0>0 == 0 and 1>0 == 1, the net effect is to simply remove the extra zero.

Loop 2: print bits until the stack is empty (D2 -> E2 -> E1 -> D2 -> D5 -> E4 -> E1)

d 1 > !    If the top exists, push 1; otherwise push 0
D          Turn right if it is 1; halt otherwise (white trap)
O          Output as number

J 2 bytes

#:

Some test cases:

   #:12345

1 1 0 0 0 0 0 0 1 1 1 0 0 1

   #:33

1 0 0 0 0 1

Knight (v2), 29 bytes

;=a@;=n*2P;W=n/n 2=a+,%n 2aOa

Try it online!

Zero outputs nothing, which is allowed in the rules.

Piet + ascii-piet, 50 44 42 bytes (2×25=50 2×22=44 2×21=42 codels)

tabru?qd?t?itknmdjem_  a?liqdltailckt?iq ?

Try Piet online!

Pointer Path

Simply, 17 bytes

The code simply creates an anonymous arrow function that calls the &tb function, and returns the result.

fn($x)=>&tb($x 2)

To use this function, assign it to a variable and call it:

$fn = fn($x)=>&tb($x 2)

echo call $fn(5);

What does &tb do?

The function &tb is a built-in alias to &tobase.

This is the result of running echo &doc(&tobase);:

Documentation for tobase:
Converts the integer $number to the $base.
The $base must be between 1 and 36, otherwise, returns null.
E.g.: tobase(10, 10) = "10", tobase(10, 2) = "1010", tobase(10, 1) = "1111111111".

Ungolfed

You can rewrite the code like this:

Set the variable $fn to an anonymous function with the argument $number.
Begin.
    Return the result of calling the function &tobase with the arguments $number and 2;
End.

Or, if you want it to be more code-like:

$fn = anonymous function($number) {
    return &tobase($number, 2);
};

CJam, 2 bytes

Yb

Try it online!

Link includes test cases

Explanation

 b # Convert to base
Y  # builtin *2*

For fun, here's one which pads to 16 bits:

CJam, 6 bytes

YbGTe[

Try it online!

Explanation

 b    # Convert to base
Y     # builtin *2*
   e[ # and pad to length
 G    # builtin *16*
      # with
  T   # zeroes

R, 9 bytes

intToBits

Attempt This Online!

Outputs as little-endian with trailing zeros.


R, 18 bytes

\(n)n%/%2^(n:0)%%2

Attempt This Online!

Outputs as big-endian (standard convention) with possibly a lot of leading zeros.

Jelly, 1 byte

B

Try it online!

Lmao my first answer in Jelly. Just a builtin.

Alice, 25 bytes

/O \v$.:2[!<
@Mq/>.2%'0+^

Try it online!

This explanation below are still valid, I just reorganised the flow to save two bytes

/ M \w.2%'0+![2:.$K/ q O @   Full program (includes a new line)
/ M \                        Reads the argument
     w          .$K          Main loop
      .2%                    Gets the modulus by two of the number
         '0+![               Store the modulus + the char code of 0 to the tape
              2:             Divide the number by 2
                   / q O @   Join the tape, output and exit

Swift, 55 49 20 bytes

-6 bytes thanks to @RydwolfPrograms
-29 bytes thanks to @Jacob
{String($0,radix:2)}

Try it online!

SNOBOL4 (CSNOBOL4), 70 bytes

	I =INPUT
N	O =REMDR(I,2) O GT(I)	:F(O)
	I =I / 2	:(N)
O	OUTPUT =O
END

Try it online!

Charcoal, 3 bytes

⍘N²

Try it online! Link is to verbose version of code. Explanation:

 N  Input as a number
⍘   Convert to base as a string
  ² Literal integer `2`
    Implicitly print

16 bytes without base conversion builtins:

P0NθWθ«←§01θ≧÷²θ

Try it online! Link is to verbose version of code. Explanation:

P0

Output 0 by default (not strictly necessary according to the question definition but the builtin version does this).

Nθ

Input the integer.

Wθ«

Repeat until it is zero.

←§01θ

Output the least significant bit of the integer, moving right-to-left. (←I﹪θ² would also work for the same byte count.)

≧÷²θ

Integer divide the integer by 2.

Pure Bash (no external utilities), 37

b()(((a=$1/2))&&b $a
echo -n $[$1%2])

Try it online!

This is a recursive function b() that takes its argument and divides by 2. If the result is non-zero, then b() is recursively called with the result. After the recursive call, the remainder when the argument is divided by 2 is the current binary digit. This is a pretty standard base conversion by repeated division by 2, with remainders becoming digits in base 2. Making it a recursive function has a couple of advantages here:

Ungolfed and perhaps a bit more readable:

function b() {
    a=$(( $1 / 2 ))
    if (( $a != 0 )); then
        b $a
    fi
    echo -n $(( $1 % 2 ))
}

Haskell, 62 bytes

import Data.Sequence
d 0=Nothing
d n=Just$divMod n 2
unfoldl d

Attempt This Online!

A different approach than Aiden Chow's answer; this one uses unfoldl from Data.Sequence, which is elegant but unfortunately much less golfy.

Explanation

unfold is conceptually the opposite of fold. fold takes a function that combines two values into one and a sequence of values, and returns a single value; unfold takes a function that splits one value into two and a single value, and returns a sequence of values. Specifically, the type of unfoldl looks like this:

unfoldl :: (b -> Maybe (b, a)) -> b -> Seq a

It takes a function and a single value of type b and returns a sequence of values of type a. The function must take a value of type b and return either a tuple containing one b and one a or Nothing. unfoldl applies the function repeatedly to the initial value, taking the first element of the tuple as the new value and saving off the second tuple elements as the sequence. It stops when it gets Nothing instead of a tuple.

In our case, both types are Int. We want the first element of the tuple to be the input int-divided by 2, and the second element to be the input mod 2. Conveniently, Haskell has a divMod function that returns exactly the tuple we want. Thus, our binary converter is just

unfoldl d

where d is a function that stops when it hits 0:

d 0 = Nothing

and otherwise returns the result of divMod wrapped in a Maybe:

d n = Just (divMod n 2)

Quipu, 78 bytes

2&1@0&2&0&3&
//**[][][][]
1&2&2&++1&/\
>>>>%%  --
\/1&1&  0&
    []  >>
    **

Attempt This Online!

Explanation

Programs in Quipu consist of several "threads," vertical strips of code that are executed one at a time and also store values. Quipu is missing a lot of features that would have been useful for this challenge: lists, string concatenation, exponentiation... Lacking better methods, we generate the output as a base-10 number whose digits are either 0 or 1.

The first time thread 0 is executed, it loads the input number; subsequently, it divides its value by 2:

    # Previous value of this thread (implicit; initially 0)
2&  # Push 2
//  # Divide
1&  # Push 1
>>  # Go to that thread if the above result is greater than 0
\/  # Otherwise, read input number

Thread 1 generates successive powers of 10, starting at 1:

    # Previous value of this thread
1@  # Push 10
**  # Multiply
2&  # Push 2
>>  # Go to that thread if the above result is greater than 0
1&  # Otherwise, push 1

Thread 2 takes the current value mod 2 and multiplies by the appropriate power of 10:

0&  # Push 0
[]  # Load that thread's value
2&  # Push 2
%%  # Mod
1&  # Push 1
[]  # Load that thread's value
**  # Multiply

Thread 3 keeps a running sum of the values generated by thread 2. This will be our output number.

    # Previous value of this thread
2&  # Push 2
[]  # Load that thread's value
++  # Add

Thread 4 tests if the value in thread 0 is still greater than 1; if so, jump back to thread 0:

0&  # Push 0
[]  # Load that thread's value
1&  # Push 1
--  # Subtract
0&  # Push 0
>>  # Go to that thread if the above result is greater than 0

Once thread 0's value has reached 1 (or 0), execution continues with thread 5, which simply outputs the final result:

3&  # Push 3
[]  # Load that thread's value
/\  # Print

Piet + ascii-piet, 73 bytes (7×12=84 codels)

um    R metabrujjL    ?  ll?dD    j  d ?T    l rr tN   ttbj nfI        nn

Try Piet online!

APL(Dyalog Extended), 9 1 byte SBCS

Try it on APLgolf!

Literally a builtin... What more can I say?

PARI/GP, 6 bytes

binary

Attempt This Online!

flax, 1 byte

B

Attempt This Online!

Builtin

PHP, 6 bytes

decbin

Try it online!

No PHP answer yet? Surprisingly competitive this time!!!

Haskell, 31 bytes

f 0=0
f n=n`mod`2+10*f(n`div`2)

Try it online!

I'm unsure why f$n`div`2 doesn't work as opposed to f(n`div`2)... I hope someone can explain this to me and help golf this code.

GeoGebra, 23 bytes

a
InputBox(a
ToBase(a,2

Try It On GeoGebra!

Befunge-93 (PyFunge), 28 bytes

2&v
2/>:0`!#^_:2%\
 ._@#-2:<

Try it online!

Explanation:

2&v and > below: Push 2 (used as an "end of string" character of sorts), push user input (henceforth X), then go down and enter the main loop.

Main Loop

:0\`!: Check if X is greater than 0. Invert the answer. (Specifically: duplicate X, push 0, swap, greater than, invert)

#^_: If top of stack is 1 (i.e. X <= 0), go up to print loop, else continue right. (Bridge, (up), horizontal if)

:2%: Get X%2. (Duplicate X, push 2, modulo)

\: Store below X on stack. (Swap)

2/: Divide X by 2. Loop restarts with this as X. (push 2, integer divide)

Print Loop

<: Go left. (going right here would add a ! but it would not increase bytes as we have a spare whitespace on the left)

-2:: Check if top of stack = 2 (end of string). (RTL; duplicate, push 2, subtract)

_@#: Terminate program if top of stack = 0 (i.e. next item is 2). (RTL; bridge, (terminate), horizontal if)

.: Print top of stack as integer.

Note: I originally had a $ to pop the leading 0 above the ^ in the main loop, but as per comments, leading 0s are allowed. Changing the ^ to a v would be equivalent, unless I were to add back in the $ at the cost of 6 vs 10 bytes.

Desmos, 50 bytes

f(n)=mod(floor(n/2^{[floor(log_2(n+0^n))...0]}),2)

Try It On Desmos!

Try It On Desmos! - Prettified

J, 2 bytes

#:

Attempt This Online!

#: returns the binary expansion of a given number y as a boolean list.

Pip, 3 bytes

TBa

Try It Online!

Builtin that converts to binary (TB). a is the input integer

Scala, 16 bytes

_.toBinaryString

Try it Online! I took some inspiration from the Java solution's boilerplate to hide the type inference elsewhere.

Excel, 11 bytes

=BASE(A1,2)

Straightforward built-in. Input is in the cell A1 and can be anything from 0 to 253-1. Formula goes in any other cell in the sheet.

dc, 4 bytes

2o?p

Try it online!

Julia 0.7, 3 bytes

bin

Try it online!

Julia 1.x, 9 bytes

bitstring

Attempt This Online!

Prints with leading zeroes.

MATL, 1 byte

B

Try it at MATL Online

Ruby -n, 8 bytes

p"%b"%$_

Attempt This Online!

C# (.NET Core), 24 bytes

x=>Convert.ToString(x,2)

Try it online!

Python 2, 62 54 bytes

i,o=input(),""
while i:i,j=divmod(i,2);o=`j`+o
print o

Try it online!

Just as a way of doing it without any builtins.

Arturo, 15 bytes

$=>[as.binary&]

Try it

Factor, 4 bytes

>bin

Try it online!

Risky, 1.5 bytes

?}2

Try it online!

?}2
 }  Convert
?   input
 }  to base
  2 2

Nim, 45 bytes

import strformat
func b(n:int):auto= &"{n:b}"

Attempt This Online!

Nibbles, 1.5 bytes

``@

Attempt This Online!

Built-in.

Pyt, 1 byte

ɓ

Try it online!

Built-ins ftw

Retina 0.8.2, 23 bytes

.+
$*
+`(1+)\1
$+0
01
1

Try it online! Link includes test cases. Code is taken from the Retina 0.8.2 unary arithmetic tutorial for decimal to unary and unary to binary, except that for decimal to unary, the input is assumed to be decimal, so . is used instead of \d, and for unary to binary, ${1} is golfed to $+.

Brachylog, 1 byte

Try it online!

Whitespace, 70 bytes

[S S S N
_Push_0][S N
S _Duplicate_0][T   N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve_input_n][N
S S N
_Create_Label_BINARY_LOOP][S N
S _Duplicate_n][N
T   S S N
_If_0_Jump_to_Label_PRINT_LOOP][S N
S _Duplicate_n][S S S T S N
_Push_2][T  S T T   _Modulo][S N
T   _Swap_top_two][S S S T  S N
_Push_2][T  S T S _Integer_divide][N
S N
N
_Jump_to_Label_BINARY_LOOP][N
S S S N
_Create_Label_PRINT_LOOP][T N
S T _Print_as_integer][N
S N
S N
_Jump_to_Label_PRINT_LOOP]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.

Try it online (with raw spaces, tabs and new-lines only).

Outputs with one additional leading 0. This can be removed at the cost of 8 additional bytes:
Try it online.

Explanation in pseudo-code:

Integer n = STDIN as integer
Start BINARY_LOOP:
  If n==0:
    Jump to PRINT_LOOP
  Push n modulo-2 to the stack
  n = n integer-divided by 2
  Go to the next iteration of BINARY_LOOP

PRINT_LOOP:
  Print current top of the stack as integer to STDOUT
  Go to the next iteration of PRINT_LOOP

Stops the program with an error when it tries to print while the stack is empty.

Wolfram Language (Mathematica), 18 bytes

#~IntegerString~2&

Try it online!

Brain-Flak, 132 bytes

{(({})<><(()())>)({}(<>))<>{(({})){({}[()])<>}{}}{}<>([{}()]{})<>({}<(()())>)({}(<>))<>([()]{()<(({})){({}[()])<>}{}>}{}<><{}{}>)}<>

Outputs the individual numbers in a list with newlines as separators, and does not output anything for 0.

Explanation:

{                                                                   #  loop while top of left stack is not 0
(({})<><(()())>)({}(<>))<>{(({})){({}[()])<>}{}}{}<>([{}()]{})<>    #  leave the result of modulo 2 on right stack
({}<(()())>)({}(<>))<>([()]{()<(({})){({}[()])<>}{}>}{}<><{}{}>)    #  integer division by 2 on left stack
}                                                                   #  end loop
<>                                                                  #  switch to right stack
                                                                    #  implicit output of active (right) stack

Try it online!

I'm not the best at this language so I may have left a lot of room for further golfing, please let me know if you found a better way to do it.

Java 8, 18 bytes

n->n.toString(n,2)

Try it online.

Explanation:

n->               // Method with Integer parameter and String return-type
  n.toString(n,2) //  Convert and return the given Integer as base-2 String

MathGolf, 1 byte

à

Try it online.

Explanation:

à  # Convert the (implicit) input-integer to a binary-string
   # (after which the entire stack is output implicitly as result)

Irrelevant note: â (convert to a binary-list) isn't an equal-byte alternative, since it (for whatever reason) outputs in reversed order.

C (GCC), 21 bytes

f(n){printf("%b",n);}

Attempt This Online!

Will be pretty shocked if there is any way to do it shorter in C (unless I missed a weird print function).

bc - 14 bytes

obase=2;read()

Run bc by typing bc into a terminal and pressing Enter. Type this code in, press Enter, type in the number to convert, and finally press Enter one more time. Press Ctrl + C to exit bc.

read() reads user input (in base 10 by default), and then obase=2 sets it to output in binary. Given that we don't tell it to do any math operations (other than base-conversion), it just outputs the input, but in binary due to the obase=2.

Example:

$ bc
bc 1.07.1
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
obase=2;read()    <-- Press Enter
1234              <-- Press Enter again
10011010010       <-- Press Ctrl + C to exit
^C
(interrupt) Exiting bc.

I've tested this on Arch Linux, but any system with bc installed should work.

05AB1E, 1 byte

b

Try it online!

Vyxal, 1 byte

b

Try it Online!

Thunno, \$ 1\log_{256}(96)\approx \$ 0.82 bytes

b

Attempt This Online!

K (ngn/k), 2 bytes

2\

Try it online!

Python, 13 bytes

"{:b}".format

Attempt This Online!

Python, 17 bytes

lambda n:f"{n:b}"

Attempt This Online!

JavaScript, 16 bytes

x=>x.toString(2)

Try it online!

Python 3, 19 bytes

lambda n:bin(n)[2:]