n
is less than or equal to 3, return n - 1
since we must perform at least one split and splitting into 1s would not be beneficial.n
is divisible by 3, return 3^(n/3)
.n
modulo 3 is 1, return 3^((n/3) - 1) * 4
.n
modulo 3 is 2, return 3^(n/3) * 2
.