This language bar is your friend. Select your favorite languages!
Edit summary for version 10 :

Version 9

Version 10

Idiom #76 Binary digits from an integer

Create the string s of integer x written in base 2.

E.g. 13 -> "1101"

Idiom #76 Binary digits from an integer

Create the string s of integer x written in base 2.

E.g. 13 -> "1101"

Code
var Iter,n:integer;
[...]
 S := '';
  for Iter := 0 to n do
    if (x shr Iter) and 1 = 0 then
      S := '0' + S
    else
      S := '1' + S;