I was wondering if there is mathematical formula or a way to get the nth binary number where n is given. Obviously, this is a very easy problem for a programmer and I can construct a program (using loops) to find it but am interested in a mathematical way to obtain it.
To give an example if we assume 0 is the 0th binary number, and 1 is the first, I would like to get 1001 when I ask about the 9th number. Another way to put this is, does a fast way exist to convert decimal numbers into binary.
What about the general case? Does a formula exist that can quickly convert a number from a numerical system in base x to one in base y?
Thank you in advance!
The $n$-th binary number is just the number $n$ written in the binary number system.
And then... there is a well-known algorithm how to obtain the binary representation of $n$.
But OK... if you mean if there's a formula for the binary digits of $n$, given $n$ itself - no, not a good/easy one at least. So you just need to keep dividing by $2$ (in a loop), and keep collecting the remainders (i.e. the binary digits).
The number of times to repeat the operation (dividing by $2$ and getting the remainder) is basically $\log_2 n$. Because each natural number $n$ has about $log_b\ n$ digits in a number system with base $b$.