Maximize the product of two integer variables with given sum Let's say we have a value $K$. I want to find the value where
$A+B = K$ (all $A,B,K$ are integers) where $AB$ is the highest possible value.
I've found out that it's:


*

*$a = K/2$; $b = K/2$; when $K$ is even 

*$a = (K-1)/2$; $b = ((K-1)/2)+1$; when $K$ is odd.
But is there a way to prove this?

We know that $B = K-A$. So you want to maximize $AB = A(K-A)$. So we have:
$$AB = A(K-A)$$
$$ = AK-A^2$$
Find the critical points and use some derivative tests.
