public int countAs(int n){
        if(n < 7){
            return n;
        }
        
        int T[] = new int[n+1];
        for(int i=1; i < 7 ; i++){
            T[i] = i;
        }
        for(int i=7; i <= n; i++){
            for(int b = i-3; b > 0; b--){
                T[i] = Math.max(T[i], T[b]*(i-b-1));
            }
        }
        return T[n];
    }
http://www.geeksforgeeks.org/how-to-print-maximum-number-of-a-using-given-four-keys/
Test cases
Negative number
Number less than 7
Number greater than equal to 7
src/com/interview/dynamic/CountAs.java