Home > front end >  Product Of Sum and Difference in Python
Product Of Sum and Difference in Python

Time:06-23

You are given two integers, a and b. Compute the Sum and Difference of a and b. Return the Product of Sum and Difference.

CodePudding user response:

d=a b
c*a-b
re=c*d

the d is sum, c is difference, and the re is the product of sum and difference.

CodePudding user response:

def product_of_sum_and_diff(a, b):
    return a**2 - b**2

this works because of the third binomial formula (a b)*(a-b)=a²-b²

  • Related