Guest User

Untitled

a guest
Jun 19th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. public class hailstonecode {
  2.  
  3. /**
  4. * @param args
  5. */
  6. public static void main(String[] args) {
  7.  
  8. int x = 27;
  9.  
  10. while (x > 1) {
  11.  
  12. if (x % 2 == 0)
  13. x = (x / 2);
  14. System.out.println(x);
  15.  
  16. if (x % 2 == 1)
  17. x = ((x * 3) + 1);
  18. System.out.println(x);
  19.  
  20. }
  21.  
  22. }
  23.  
  24. }
Add Comment
Please, Sign In to add comment