This problem is about break n in to x numbers, each number is about n/x, want to maximize (n/x)^x
lets take y=(n/x)^x
dlog(y)/dx=(log(n)-log(x))+x*(-1/x) set derivative to 0 to maximize
In other works, you want to break the number to as many e's as possible.
but since we need to break it into integer, the closest is 3.
so break n in to as many 3's as possible.
here is the code:
if n==2: return 1 if n==3: return 2 if n==4: return 4 if n==5: return 6 k=n%3 x=n//3 if k==0: return 3**x if k==1: return 3**(x-1)*4 else: return 3**x*2