You are given four numbers num1, den1, num2, and den2. You need to find (num1/den1)+(num2/den2) and output the result in the form of (numx/denx). 
Input Format:
The first line of input contains an integer T denoting the number of test cases . Then T test cases follow . Each test case contains four integers num1, den1, num2, den2 respectively .
Output Format:
For each test case, in a new line,  output will be the fraction in the form a/b where the fraction denotes the sum of the two given fractions in reduced form.
Your Task:
Since this is a function problem, you don't need to worry about the testcases. Your task is to complete the function addFraction  which adds the two fractions and prints the resulting fraction. The function takes four arguments num1, den1, num2, den2 where num1, num2 denotes the numerators of two fractions and den1, den2 denotes their denominators.
Constraints:
1 <= T <= 100
1 <= den1,den2,num1,num2 <= 1000
Example:
Input
1
1 500 2 500
Output
3/500
Explanation:
In above test case 1/500+2/500=3/500
 
Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #Your task is to complete this function

#Your shouldn't return any thing it should print the required output

def addFraction(num1, den1, num2, den2):

    #Code here

Solutions:
def addFraction(num1, den1, num2, den2):
	from math import gcd
	num = num1 * den2 + num2 * den1
	den = den1 * den2
	ka = gcd(num, den)
	h = num // ka
	d = den // ka
	print(str(h) + '/' + str(d))


def find_gcd(a, b):
	if a >= b:
		x = a
		y = b
	else:
		x = b
		y = a
	remainder = y
	while x % y != 0:
		remainder = x % y
		x = y
		y = remainder
	return remainder

def find_lcm(a, b, gcd):
	return int(a * (b / gcd))

def addFraction(num1, den1, num2, den2):
	gcd = find_gcd(den1, den2)
	lcm = find_lcm(den1, den2, gcd)
	num = lcm / den1 * num1 + lcm / den2 * num2
	den = lcm
	ans_gcd = find_gcd(num, den)
	ans = str(int(num / ans_gcd)) + '/' + str(int(den / ans_gcd))
	print(ans)


def gcd(a, b):
	(a, b) = (max(a, b), min(a, b))
	r = a % b
	while r != 0:
		a = b
		b = r
		r = a % b
	return b

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

def addFraction(num1, den1, num2, den2):
	if den1 == den2:
		(num, den) = (num1 + num2, den1)
	else:
		den = lcm(den1, den2)
		(f1, f2) = (den // den1, den // den2)
		(num1, num2) = (num1 * f1, num2 * f2)
		num = num1 + num2
	gnd = gcd(num, den)
	(num, den) = (num // gnd, den // gnd)
	print(str(num) + '/' + str(den))


def addFraction(num1, den1, num2, den2):
	from fractions import Fraction
	n = num1 * den2 + num2 * den1
	d = den1 * den2
	print(str(Fraction(n, d)))


def addFraction(num1, den1, num2, den2):
	lcmfac = 0
	if den1 > den2:
		digit1 = den1
		digit2 = den2
	else:
		digit1 = den2
		digit2 = den1
	for i in range(1, 10000):
		digi = 0
		digi = digit1 * i
		if digi % digit2 == 0:
			lcmfac = digi
			break
	d1 = lcmfac // den1
	d2 = lcmfac // den2
	add = d1 * num1 + d2 * num2
	for j in range(1, 10000):
		if add % j == 0 and lcmfac % j == 0:
			no = j
			n1 = add // j
			n2 = lcmfac // j
	print('{}/{}'.format(n1, n2))


import math

def addFraction(num1, den1, num2, den2):
	if den1 == den2:
		print(str(num1 + num2) + '/' + str(den1))
	else:
		a = num1 * den2 + num2 * den1
		b = den1 * den2
		g = math.gcd(a, b)
		print(str(a // g) + '/' + str(b // g))


def addFraction(num1, den1, num2, den2):
	dn = int(den1 * den2 / gcd(den1, den2))
	mpt1 = int(dn / den1)
	mpt2 = int(dn / den2)
	nm = mpt1 * num1 + mpt2 * num2
	gcdnd = int(gcd(max(dn, nm), min(dn, nm)))
	print(str(int(nm / gcdnd)) + '/' + str(int(dn / gcdnd)))

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)


def gcd(A, B):
	rem = 1
	if A > B:
		divident = A
		divisor = B
	else:
		divident = B
		divisor = A
	while rem != 0:
		rem = divident % divisor
		if rem != 0:
			divident = divisor
			divisor = rem
	return divisor

def addFraction(num1, den1, num2, den2):
	nu = num1 * den2 + num2 * den1
	de = den1 * den2
	g = gcd(nu, de)
	n = str(nu // g).strip(' ')
	d = str(de // g).strip(' ')
	print(n + '/' + d)


import math

def addFraction(num1, den1, num2, den2):
	num = num1 * den2 + num2 * den1
	den = den1 * den2
	gcd = math.gcd(num, den)
	num = int(num / gcd)
	den = int(den / gcd)
	print(num, end='')
	print('/', end='')
	print(den)


def addFraction(num1, den1, num2, den2):
	from fractions import Fraction as frac
	n = num1 * den2 + num2 * den1
	d = den1 * den2
	print(frac(n, d))


def addFraction(num1, den1, num2, den2):
	import math
	nums = num1 * den2 + num2 * den1
	dens = den1 * den2
	gcd = math.gcd(nums, dens)
	print(str(int(nums / gcd)) + '/' + str(int(dens / gcd)))


def gcd(a, b):
	remain_prev_prev = max(a, b)
	remain_prev = min(a, b)
	remain_cur = 0
	while True:
		remain_cur = remain_prev_prev % remain_prev
		if remain_cur == 0:
			break
		remain_prev_prev = remain_prev
		remain_prev = remain_cur
	return remain_prev

def addFraction(num1, den1, num2, den2):
	num_ans = num1 * den2 + num2 * den1
	den_ans = den1 * den2
	gcd_ans = gcd(den_ans, num_ans)
	num_simp = num_ans // gcd_ans
	den_simp = den_ans // gcd_ans
	print('%d/%d' % (num_simp, den_simp))


from fractions import Fraction

def addFraction(num1, den1, num2, den2):
	a = num1 * den2 + num2 * den1
	b = den1 * den2
	print(str(Fraction(a, b)))


from fractions import Fraction

def addFraction(num1, den1, num2, den2):
	if den1 == den2:
		return num1 * num2 / den1
	else:
		dres = den1 * den2
		nres = num1 * den2 + num2 * den1
		frac = Fraction(nres, dres)
		print(frac)


def addFraction(num1, den1, num2, den2):
	from fractions import Fraction
	if den1 == den2:
		num = num1 + num2
		num = str(num)
		den1 = str(den1)
		frac = num + '/' + den1
		print(frac)
	else:
		den = den1 * den2
		num1 = num1 * den2
		num2 = num2 * den1
		num = num1 + num2
		frac = Fraction(num, den)
		print(frac)


def addFraction(num1, den1, num2, den2):
	num = num1 * den2 + num2 * den1
	den = den1 * den2

	def gcd(a, b):
		if b == 0:
			return a
		return gcd(b, a % b)
	gcdd = gcd(num, den)
	num = num // gcdd
	den = den // gcdd
	print(str(num) + '/' + str(den))


from math import gcd

def addFraction(num1, den1, num2, den2):
	numx = num1 * den2 + num2 * den1
	denx = den1 * den2
	hcf = gcd(numx, denx)
	print('{}/{}'.format(numx // hcf, denx // hcf))


def gcd(a, b):
	if not b:
		return a
	return gcd(b, a % b)

def addFraction(n1, d1, n2, d2):
	result_n = n1 * d2 + n2 * d1
	result_d = d1 * d2
	result_gcd = gcd(result_n, result_d)
	result_n //= result_gcd
	result_d //= result_gcd
	print(result_n, result_d, sep='/')


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def addFraction(x1, y1, x2, y2):
	x3 = x1 * y2 + x2 * y1
	y3 = y1 * y2
	(x3, y3) = (x3 // gcd(x3, y3), y3 // gcd(x3, y3))
	print(x3, end='')
	print('/', end='')
	print(y3)


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def addFraction(num1, den1, num2, den2):
	den_mul = den1 * den2
	num_mul = num1 * den2 + num2 * den1
	g = gcd(den_mul, num_mul)
	print('{}/{}'.format(int(num_mul / g), int(den_mul / g)))


def addFraction(num1, den1, num2, den2):

	def gcd(a, b):
		if b == 0:
			return a
		else:
			return gcd(b, a % b)

	def lowest(c, d):
		e = gcd(c, d)
		f = int(c / e)
		g = int(d / e)
		return print(str(f) + '/' + str(g))
	lcm = den1 * den2 / gcd(den1, den2)
	num3 = int(num1 * (lcm / den1)) + int(num2 * (lcm / den2))
	return lowest(num3, lcm)


def addFraction(num1, den1, num2, den2):
	newnum = num1 * den2 + num2 * den1
	newden = den1 * den2
	divisor = newnum
	dividend = newden
	while divisor > 0:
		val = divisor
		divisor = dividend % divisor
		dividend = val
	newnum = newnum / dividend
	inewnum = int(newnum)
	newden = newden / dividend
	inewden = int(newden)
	print(str(inewnum) + '/' + str(inewden))
	return 0


def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def addFraction(num1, den1, num2, den2):
	den3 = gcd(den1, den2)
	den3 = den1 * den2 / den3
	num3 = num1 * (den3 / den1) + num2 * (den3 / den2)
	cf = gcd(num3, den3)
	den3 = den3 / cf
	num3 = num3 / cf
	print('%d/%d' % (num3, den3))


def addFraction(num1, den1, num2, den2):

	def lcm(den1, den2):
		rem = 1
		a = den1
		b = den2
		while rem != 0:
			if den1 > den2:
				rem = den1 % den2
				if rem == 0:
					gcd = den2
					break
				den1 = den2
				den2 = rem
			else:
				rem = den2 % den1
				if rem == 0:
					gcd = den1
					break
				den2 = den1
				den1 = rem
		return a * b // gcd
	lcm = lcm(den1, den2)
	num = lcm // den1 * num1 + lcm // den2 * num2
	rem = 1
	x = max(lcm, num)
	y = min(lcm, num)
	while rem > 0:
		rem = x % y
		if rem == 0:
			gcd = y
			break
		x = y
		y = rem
	num = num // y
	lcm = lcm // y
	print(str(num) + '/' + str(lcm))


def addFraction(num1, den1, num2, den2):

	def lcm(den1, den2):
		rem = 1
		a = den1
		b = den2
		while rem != 0:
			if den1 > den2:
				rem = den1 % den2
				if rem == 0:
					gcd = den2
					break
				den1 = den2
				den2 = rem
			else:
				rem = den2 % den1
				if rem == 0:
					gcd = den1
					break
				den2 = den1
				den1 = rem
		return a * b // gcd
	lcm = lcm(den1, den2)
	num = lcm // den1 * num1 + lcm // den2 * num2
	z = list(range(2, int(min(lcm, num) ** 0.5)))
	for i in z:
		while num % i == 0 and lcm % i == 0:
			num = num // i
			lcm = lcm // i
	print(str(num) + '/' + str(lcm))


def addFraction(num1, den1, num2, den2):

	def hcf(x, y):
		if x == 0:
			return y
		return hcf(y % x, x)
	n = num1 * den2 + num2 * den1
	d = den1 * den2
	gcd = hcf(n, d)
	num = n // gcd
	den = d // gcd
	print(str(num) + '/' + str(den))


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

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

def addFraction(num1, den1, num2, den2):
	den = lcm(den1, den2)
	num = num1 * (den // den1) + num2 * (den // den2)
	gcdND = gcd(num, den)
	print(str(num // gcdND) + '/' + str(den // gcdND))


def addFraction(num1, den1, num2, den2):
	num = num1 * den2 + num2 * den1
	den = den1 * den2
	maxi = max(num, den)
	mini = min(num, den)
	while mini:
		(maxi, mini) = (mini, maxi % mini)
	gcd = maxi
	num = int(num / gcd)
	den = int(den / gcd)
	print(str(num) + '/' + str(den))


def addFraction(num1, den1, num2, den2):
	counter = 3
	denominators = 0
	numerators = 0
	k = '/'
	if den1 == den2:
		numerators = num1 + num2
		print(str(numerators) + k + str(den1))
	else:
		denominators = den1 * den2
		num1 = num1 * den2
		num2 = num2 * den1
		numerators = num1 + num2
		while counter > 0:
			for i in range(1, 1000):
				if numerators % i == 0 and denominators % i == 0:
					numerators = numerators // i
					denominators = denominators // i
			counter -= 1
		print(str(numerators) + k + str(denominators))


from fractions import Fraction

def addFraction(num1, den1, num2, den2):
	my_nume = num1 * den2 + num2 * den1
	my_denom = den1 * den2
	print(str(Fraction(my_nume, my_denom)))


def addFraction(num1, den1, num2, den2):
	n1 = num1 * den2 + num2 * den1
	n2 = den1 * den2
	if n1 > n2:
		a = n1
		b = n2
		c = a % b
		while c != 0:
			a = b
			b = c
			c = a % b
	else:
		a = n2
		b = n1
		c = a % b
		while c != 0:
			a = b
			b = c
			c = a % b
	n1 = n1 // b
	n2 = n2 // b
	print(str(n1) + '/' + str(n2))


def addFraction(num1, den1, num2, den2):
	if den1 == den2:
		print(num1 + num2, '/', den1)
	nume = num1 * den2 + num2 * den1
	dune = den1 * den2
	a = nume
	b = dune
	if a > b:
		c = a % b
		while c != 0:
			a = b
			b = c
			c = a % b
	else:
		(a, b) = (b, a)
		c = a % b
		while c != 0:
			a = b
			b = c
			c = a % b
	nume = nume // b
	dune = dune // b
	print(str(nume) + '/' + str(dune))


from fractions import Fraction

def addFraction(num1, den1, num2, den2):
	print(Fraction(num1, den1) + Fraction(num2, den2))


from fractions import Fraction

def addFraction(num1, den1, num2, den2):
	if den1 == den2:
		s1 = num1 + num2
		s2 = den1
		s3 = s1 + '/' + s2
		print(s3)
	else:
		r1 = num1 * den2
		r2 = num2 * den1
		r3 = r1 + r2
		r4 = den1 * den2
		frac = Fraction(r3, r4)
		print(frac)


def addFraction(num1, den1, num2, den2):
	from fractions import Fraction
	if den1 == den2:
		num3 = num1 + num2
		den3 = den1
		result = num3 + '/' + den3
		print(result)
	else:
		num3 = num1 * den2 + num2 * den1
		den3 = den1 * den2
		result = Fraction(num3, den3)
	print(result)


def gcd_calc(x, y):
	(big, small) = (max(x, y), min(x, y))
	while big % small != 0:
		temp = small
		small = big % small
		big = temp
	return small

def addFraction(num1, den1, num2, den2):
	gcd = gcd_calc(den1, den2)
	initial_num = num1 * den2 // gcd + num2 * den1 // gcd
	initial_den = den1 * den2 // gcd
	gcd = gcd_calc(initial_num, initial_den)
	num = initial_num // gcd
	den = initial_den // gcd
	print('{}/{}'.format(num, den))


def findGcd(A, B):
	while A != B:
		if A < B:
			B -= A
		else:
			A -= B
	return A

def addFraction(num1, den1, num2, den2):
	if den1 == den2:
		num = num1 + num2
		den = den1
	else:
		gcd = findGcd(den1, den2)
		lcm = den1 * den2 // gcd
		num1 = num1 * lcm // den1
		num2 = num2 * lcm // den2
		num = num1 + num2
		den = lcm
	common_factor = findGcd(num, den)
	num = num // common_factor
	den = den // common_factor
	print('{}/{}'.format(num, den))


import math

def addFraction(num1, den1, num2, den2):
	lcm = den1 * den2 // math.gcd(den1, den2)
	a = lcm // den1 * num1 + lcm // den2 * num2
	p = math.gcd(a, lcm)
	print('{}/{}'.format(a // p, lcm // p))


import fractions

def addFraction(num1, den1, num2, den2):
	f1 = fractions.Fraction(num1, den1)
	f2 = fractions.Fraction(num2, den2)
	f3 = f1 + f2
	print(f3)


import math

def addFraction(num1, den1, num2, den2):
	num1 = den2 * num1
	num2 = den1 * num2
	den1 = den1 * den2
	p = num1 + num2
	pp = math.gcd(p, den1)
	print(str(p // pp) + '/' + str(den1 // pp))


def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def addFraction(num1, den1, num2, den2):
	g = gcd(den1, den2)
	l = int(den1 * den2 / g)
	num3 = num1 * (l / den1) + num2 * (l / den2)
	cf = gcd(num3, l)
	l = str(int(l / cf))
	num3 = str(int(num3 / cf))
	print(num3 + '/' + l)


def addFraction(num1, den1, num2, den2):
	import math
	a = num1 * den2 + num2 * den1
	b = den1 * den2
	n = min(a, b)
	for i in range(2, int(math.sqrt(n)) + 1):
		while a % i == 0 and b % i == 0:
			a //= i
			b //= i
	print(a, '/', b, sep='')


def addFraction(num1, den1, num2, den2):
	if den1 == den2:
		print('{}/{}'.format(num1 + num2, den2))
		return
	d = den1 * den2
	n1 = den1 * num2
	n2 = den2 * num1
	n = n1 + n2
	s = min(n, d)
	b = max(n, d)
	while s > 0:
		g = b % s
		b = s
		s = g
	if b != 1:
		n = n // b
		d = d // b
	print('{}/{}'.format(n, d))


import math

def addFraction(num1, den1, num2, den2):
	n = num1 * den2 + num2 * den1
	d = den1 * den2
	g = math.gcd(d, n)
	n = n / g
	d = d / g
	print('%d/%d' % (n, d))


import math

def addFraction(num1, den1, num2, den2):
	nu = num1 * den2 + num2 * den1
	de = den1 * den2
	g = math.gcd(nu, de)
	nu = nu // g
	de = de // g
	print(str(nu) + '/' + str(de))


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def addFraction(num1, den1, num2, den2):
	num = num1 * den2 + num2 * den1
	den = den1 * den2
	gcd_ = gcd(num, den)
	print(str(int(num / gcd_)) + '/' + str(int(den / gcd_)))


def addFraction(num1, den1, num2, den2):
	from fractions import Fraction
	x = num1 * den2
	y = num2 * den1
	z = den1 * den2
	z1 = x + y
	print(str(Fraction(z1, z)))


def addFraction(num1, den1, num2, den2):
	num = num1 * den2 + num2 * den1
	deno = den1 * den2

	def hcf(num1, num2):
		if num1 % num2 == 0:
			return num2
		return hcf(num2, num1 % num2)
	dvd = hcf(num, deno)
	num = num // dvd
	deno = deno // dvd
	print(str(num) + '/' + str(deno))


import math

def addFraction(num1, den1, num2, den2):
	num = num1 * den2 + num2 * den1
	den = den1 * den2
	k = 2
	while k < math.sqrt(min(num, den)):
		if num % k == 0 and den % k == 0:
			num = num / k
			den = den / k
		else:
			k += 1
	s = str(int(num)) + '/' + str(int(den))
	print(s)


def addFraction(num1, den1, num2, den2):
	from fractions import Fraction
	if den1 == den2:
		n = num1 + num2
	else:
		d = den1 * den2
		n = num1 * den2 + num2 * den1
	f = Fraction(n, d)
	print(f)


def addFraction(num1, den1, num2, den2):
	numerator = num1 * den2 + num2 * den1
	denominator = den1 * den2
	(numerator, denominator) = list(map(int, simplify_fraction(numerator, denominator, gcd(numerator, denominator))))
	print(str(numerator) + '/' + str(denominator))

def gcd(A, B):
	if A < B:
		divisor = A
		dividend = B
	else:
		divisor = B
		dividend = A
	while divisor % dividend != 0:
		remainder = dividend % divisor
		if remainder == 0:
			break
		else:
			dividend = divisor
			divisor = remainder
	return divisor

def simplify_fraction(N, D, HCF):
	return [N / HCF, D / HCF]