Sum of Different Pairs Calculator

  • Share this:

Code introduction


Calculate the sum of all different pairs from a list of integers.


Technology Stack : Built-in functions and loops

Code Type : Function

Code Difficulty :


                
                    
def sum_of_pairs(numbers):
    total = 0
    for i in range(len(numbers)):
        for j in range(i + 1, len(numbers)):
            total += numbers[i] + numbers[j]
    return total