int maxProduct(int length){ if(length < 2) return 0; if(length = 2) return 1; if(length = 3) return 2; int numof3 = length/3; if(length - numof3*3 == 1) numof3 -= 1; int numof2 = (length - numof3*3)/2; return (int)(pow(3,numof3))*(int)(pow(2,numof2)); }