f=lambda a,b,s=0:b/a and 2*a*s+f(a+1,b,s+a) for (a,b) in (5,9), (91,123), (1,10): print '%2d %3d -> %8d' % (a,b,f(a,b))