UVa Online Judge Challenge "100"

Problem

My Solution

 1import java.io.IOException;
 2import java.util.Scanner;
 3
 4public class Main {
 5
 6    public static void main(String[] args) throws IOException {
 7
 8        Scanner sc = new Scanner(System.in);
 9        
10        while (sc.hasNext()) {
11
12            int n1 = sc.nextInt();
13            int n2 = sc.nextInt();
14
15            if (n2  n1) {
16                int largest = 0;
17
18                for (int i = n1; i = n2; i++) {
19                    int temp = collatz(i, 1);
20                    if (temp  largest) {
21                        largest = temp;
22                    }
23                }
24                
25                System.out.println(n1 +   + n2 +   + largest);
26            } else if (n2  n1) {
27                int largest = 0;
28
29                for (int i = n2; i = n1; i++) {
30                    int temp = collatz(i, 1);
31                    if (temp  largest) {
32                        largest = temp;
33                    }
34                }
35                System.out.println(n1 +   + n2 +   + largest);
36            } else if (n2 == n1) {
37                int temp = collatz(n1, 1);
38                System.out.println(n1 +   + n2 +   + temp);
39            }
40
41        }
42    }
43
44    public static int collatz(long input, int cycleLength) {
45
46        long n = input;
47        int counter = cycleLength;
48
49        if (n == 1) {
50            return counter;
51        } else if (n % 2 != 0) {
52            n = 3  n + 1;
53            counter++;
54            return collatz(n, counter);
55        } else {
56            n = n  2;
57            counter++;
58            return collatz(n, counter);
59        }
60
61    }
62}