Skip to main content
5 of 5
added 8 characters in body
david
  • 609
  • 4
  • 13

Python 3, 66 65 bytes

lambda a,b:sum(x*y*2for x in range(a,b+1)for y in range(x+1,b+1))

Try it online!

with @Dennis formulae and w/o recursion, yet another Python solution (as I cannot comment @leaky-nun solution (not enough reputation)

david
  • 609
  • 4
  • 13