Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class hailstonecode {
- /**
- * @param args
- */
- public static void main(String[] args) {
- int x = 27;
- while (x > 1) {
- if (x % 2 == 0)
- x = (x / 2);
- System.out.println(x);
- if (x % 2 == 1)
- x = ((x * 3) + 1);
- System.out.println(x);
- }
- }
- }
Add Comment
Please, Sign In to add comment