## Python 2, 45 bytes <!-- language: lang-py --> lambda a,b:(a+~b)*(a-b)*(3*(a+b)**2+a-b-2)/12 Closed form solution - not the shortest, but I thought it'd be worth posting anyway.