public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt();
int[] tab = new int[n]; for(int i = 0; i < n; i++) tab[i] = input.nextInt();
for(int i = 0; i < n; i++) System.out.println(cell(tab[i])); } static int x = 0; public static int cell(int n) { if(n == 1) { int p = x; x = 0; return p; } x++; return n % 2 == 0 ? cell(n / 2) : cell(3 * n + 1); } }
Wyszukiwarka