s=target=8000000 a=b=0 for m in range(1,2000): for n in range(m,2000): t=target-m*n*(m+1)*(n+1) if abs(t) < s: a,b,s=m,n,abs(t) print a*b,a,b,s