Lets convert decimal base 10 number 273 to binary and store those bits as a String of 1s and 0s base case: if n == 0 just return "" (empty string) #1 Dimension an array of chars with exact number of bits to store the binary number. Each char will either be a 1 or a 0 ? How to calculate number of bits needed to represent n in binary ? A It's (log2 of n) + 1. That how big to make your char array. hint: Use java's Math.log(x) function. use identity => log2N = log(N) / log(2) You want the FLOOR of this value not rounded, not ceil so you'll have to use the int cast operator (int) around the entire quotient above. the floor or (int) of log2N is 8 and adding one you get nine. #2 fill your array of 9 chars '0' chars index 0 1 2 3 4 5 6 7 8 ----------------- the array is now 0 0 0 0 0 0 0 0 0 ----------------- how much 2 1 that bit ==> 5 2 6 3 1 worth 6 8 4 2 6 8 4 2 1 #3 convert this process into a loop until n == 0 ? what is the largest power p of 2 such that 2^p <= 273 well, n is 273 and 256 is the largest power of 2 that does not exceed 273 so the largest power p is 8 p == 8 so overwrite a '1' into the array at the slot representing the 256's. That would be index [0] array now => 1 0 0 0 0 0 0 0 0 now subtract 2^p (i.e. 256) from n i.e. n = n - 256 or n == 17 DO AGAIN with n == 17 ? what is the largest power p of 2 such that 2^p <= 17 p is 4 and 2^4 == 16 so overwrite a 1 into the bit that represents the 16s. That would be the bit at index [4] array now => 1 0 0 0 1 0 0 0 0 now subtract 16 from 17 i.e. n = n - 16 so n now == 1 DO AGAIN with n == 1 largest power of 2 where 2^p <= 1 is 1 overwrite a '1' into the array at the index of the ones that would be index [8] array now => 1 0 0 0 1 0 0 0 1 256 + 16 + 1 = 273 now subtract 1 from n ( 1 from 1 ) and n == 0 YOU ARE DONE. return a new string constructed on this char array