Ref: http://www.geeksforgeeks.org/how-to-print-maximum-number-of-a-using-given-four-keys/

```
public int maxA(int N) {
if (N <= 6) return N;
int res = 0;
for (int b = N - 3; b >= 1; b--) {
int curr = (N - b - 1) * maxA(b);
res = Math.max(res, curr);
}
return res;
}
```