In this kata you need to create a function that takes a 2D array/list of non-negative integer pairs and returns the sum of all the "saving" that you can have getting the [LCM](https://en.wikipedia.org/wiki/Least_common_multiple) of each couple of number compared to their simple product.

For example, if you are given:
```
[[15,18], [4,5], [12,60]]
```
Their product would be:
```
[270, 20, 720]
```
While their respective LCM would be:
```
[90, 20, 60]
```
Thus the result should be:
```
(270-90)+(20-20)+(720-60)==840
```
This is a kata that I made, among other things, to let some of my trainees familiarize with the [euclidean algorithm](https://en.wikipedia.org/wiki/Euclidean_algorithm), a really neat tool to have on your belt ;)

Difficulty: introductory

Starter code:

def sum_differences_between_products_and_LCMs(pairs):
	

Solutions:
from fractions import gcd

def sum_differences_between_products_and_LCMs(pairs):
    return sum(a*b - a*b//gcd(a,b) for a, b in pairs if a and b)

from fractions import gcd

def lcm(x, y):
    return x * y / gcd(x, y) if gcd(x, y) else 0
    
def sum_differences_between_products_and_LCMs(pairs):
    return sum(x*y - lcm(x, y) for x, y in pairs)


from fractions import gcd
def sum_differences_between_products_and_LCMs(pairs):
    return sum(i * j - (i * j // gcd(i, j)) for i, j in pairs if i and j)

import fractions
def sum_differences_between_products_and_LCMs(pairs):
   return sum( [pair[0]*pair[1]*(1-(1.0/fractions.gcd(pair[0], pair[1]) if fractions.gcd(pair[0], pair[1])!=0 else 0)) for pair in pairs])

gcd = lambda x,y: gcd(y,x % y) if x and x%y else y
lcm = lambda x,y: x*y / gcd(x,y) if x*y else 0
def sum_differences_between_products_and_LCMs(pairs):
    return sum(x[0]*x[1] - lcm(x[0],x[1]) for x in pairs)

from fractions import gcd
def sum_differences_between_products_and_LCMs(pairs):
    return sum(x * (y - y / (gcd(x, y) or 1)) for x, y in pairs)


gcd=lambda a,b:gcd(b,a%b) if b else a
lcm=lambda a,b:a/gcd(a,b)*b
sum_differences_between_products_and_LCMs=lambda p:sum(x*y-(lcm(x,y) if x and y else 0) for x,y in p)


from math import gcd

def sum_differences_between_products_and_LCMs(pairs):
    p=[x*y for x,y in pairs]
    lcd=[x*y/gcd(x,y) if y!=0 else 0 for x,y in pairs]
    return sum(x-y for y,x in zip(lcd,p))

from math import gcd

def sum_differences_between_products_and_LCMs(pairs):
    return sum((x[0]*x[1]-(x[0]*x[1]/(gcd(x[0],x[1])if x[1]!=0 else 1))) for x in pairs)

from math import gcd
def sum_differences_between_products_and_LCMs(pairs):
    lcm=lambda x,y:(x*y)//gcd(x,y) if x and y else 0
    return sum(x*y-lcm(x,y) for [x,y] in pairs)