Binary: convert a number to base 2
toBinary turns a whole number into a String of 0s and 1s. Step through it: each pass of the while loop finds the remainder after dividing by 2 (the next binary digit), halves n, and puts the digit at the front of bin — so the digits come out right to left.