Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement