/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { private static List<Integer> getHailstoneSeq(int n) { ArrayList<Integer> results = new ArrayList<Integer>(); results.add(n); if (n == 1) return results; int next; if (n % 2 == 0) next = n / 2; else next = 3*n + 1; results.add(next); while (next != 1) { if (next % 2 == 0) next = next / 2; else next = 3*next + 1; results.add(next); } return results; } { int n = 15; } }
Standard input is empty