fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. string binary(int i) {
  5. if (i == 1) {
  6. return "1";
  7. }
  8. else if (i%2 == 0) {
  9. return binary(i/2) + "0";
  10. }
  11. else {
  12. return binary(i/2) + "1";
  13. }
  14. }
  15. int main() {
  16. int x;
  17. cin>>x;
  18. cout<<binary(x);
  19. }
Success #stdin #stdout 0.01s 5436KB
stdin
72
stdout
1001000