Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. class playground
  2. {
  3. private int i = 0;
  4. private String Output;
  5.  
  6. public static void main(String[] args) {
  7. i = args[0].parseInt() ;
  8. iterative(i, Output);
  9. }
  10.  
  11. public void iterative(int rest, String Ausgabe)
  12. {
  13. while{rest != 0}
  14. {
  15. if (rest%2 == 0)
  16. {
  17. Ausgabe.append(0);
  18. rest = rest/2;
  19. iterative(rest, Ausgabe);
  20. }
  21. else
  22. {
  23. Ausgabe.append(1);
  24. rest = rest/2;
  25. iterative(rest, Ausgabe);
  26. }
  27. }
  28. else
  29. {
  30. print Ausgabe;
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement