Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
lambda a,b:sum(x*y*2for x in range(a,b+1) for y in range(x+1,b+1))
Try it online!Try it online!
with @Dennis formulae and w/o recursion, yet another Python solution (as I cannot comment @leaky-nun solution (not enough reputation)
Try it online!
lambda a,b:sum(x*y*2for x in range(a,b+1)for y in range(x+1,b+1))
Python, 67 66 65 bytesTry it online!
Python, 67 66 65 bytes
Python, 6767 66 65 bytes
lambda a,b:2*sumsum(x*y forx*y*2for x in range(a,b+1) for y in range(x+1,b+1))
Python, 67 bytes
lambda a,b:2*sum(x*y for x in range(a,b+1) for y in range(x+1,b+1))