I wrote a \'simple\' (it took me 30 minutes) program that converts decimal number to binary. I am SURE that there\'s a lot simpler way so can you show me? Here\'s the code:<
The conversion from natural number to a binary string:
string toBinary(int n) { if (n==0) return "0"; else if (n==1) return "1"; else if (n%2 == 0) return toBinary(n/2) + "0"; else if (n%2 != 0) return toBinary(n/2) + "1"; }