public static void main(String[] args) {
        
        long start = System.currentTimeMillis();
        byte [] sol = new byte[1000000];
        int count = 0, tmp = 0;
        int result = 0;
        ArrayList<Integer> chain = new ArrayList<>();
        
        for(int i = 0; i < sol.length; i++)
            sol[i] = Byte.MAX_VALUE;
        
        factorialTable[0] = 1;
        for(int i = 1; i < 10; i++){
            factorialTable[i] = factorial(i);
        }
        
        for(int i = 0; i < 1000000; i++){
            
            tmp = i;
            count = 0;
            while(true){
                
                if(chain.contains(tmp)){
                    sol[i] = (byte) count;
                    break;
                }
                
                if(tmp >= 1000000 || sol[tmp] == Byte.MAX_VALUE){
                    chain.add(tmp);
                    count++;
                    tmp = computeNext(tmp);
                }
                
                else{
                    count += sol[tmp];
                    sol[i] = (byte) count;
                    break;
                }
            }
            
            chain.clear();
        }
        
        for(int i = 0; i < sol.length; i++){
            if(sol[i] == 60){
                result++;
            }
        }
        
        long stop = System.currentTimeMillis();
        System.out.println("Result: " + result);
        System.out.println("Execution time: " + (stop - start));
    }