We all use 16:9, 16:10, 4:3 etc. ratios every day. Main task is to determine image ratio by its width and height dimensions. 

Function should take width and height of an image and return a ratio string (ex."16:9").
If any of width or height entry is 0 function should throw an exception (or return `Nothing`).

Source: codewars | Difficulty: EASY

Starter code: def calculate_ratio(w, h):
	

Solutions:
from fractions import Fraction

def calculate_ratio(w, h):
	if w * h == 0:
		raise ValueError
	f = Fraction(w, h)
	return f'{f.numerator}:{f.denominator}'


from fractions import gcd

def lcm(a, b):
	return a * b / gcd(a, b)

def calculate_ratio(w, h):
	if all((x > 0 for x in [w, h])):
		return '{}:{}'.format(lcm(w, h) / h, lcm(w, h) / w)
	return 'You threw an error'


from fractions import gcd

def calculate_ratio(w, h):
	if w == 0 or h == 0:
		raise ValueError
	factor = gcd(w, h)
	return '{}:{}'.format(w // factor, h // factor)


from fractions import gcd

def calculate_ratio(w, h):
	c = gcd(w, h)
	return '{}:{}'.format(w / c, h / c) if w > 0 and h > 0 else 'You threw an error'


def calculate_ratio(w, h):
	if w <= 0 or h <= 0:
		raise ValueError

	def gcd(a, b):
		while b:
			(a, b) = (b, a % b)
		return a
	denom = gcd(w, h)
	return '{}:{}'.format(w / denom, h / denom)


from math import gcd

def calculate_ratio(w, h):
	if w <= 0 or h <= 0:
		raise ValueError('Width and height should be > 0')
	d = gcd(w, h)
	return f'{w // d}:{h // d}'


def calculate_ratio(w, h):
	if not h or not w:
		raise ValueError('Width and height should be > 0')
	for i in range(2, min(w, h) + 1):
		while h % i == w % i == 0:
			h //= i
			w //= i
	return f'{w}:{h}'


def calculate_ratio(w, h):
	for i in range(1, 100000):
		if w == 0:
			return 'You threw an error'
		elif w / h * i - int(w / h * i) == 0:
			return str(int(w / h * i)) + ':' + str(i)
		elif h / w * i - int(h / w * i) == 0:
			return str(i) + ':' + str(int(h / w * i))
	return 'You threw an error'