Given two values ‘a’ and ‘b’ that represent coefficients in “ax – by = 0”, find the smallest values of x and y that satisfy the equation. It may also be assumed that x > 0, y > 0, a > 0 and b > 0.
Example 1:
Input: a = 25, b = 35
Output: 7 5
Explaination: 25*7 - 35*5 = 0. And x = 7 
and y = 5 are the least possible values 
of x and y to get the equation solved.
Example 2:
Input: a = 3, b = 7
Output: 7 3
Explaination: For this case x = 7 and 
y = 3 are the least values of x and y 
to satisfy the equation.
Your Task:
You do not need to read input or print anything. Your task is to complete the function findXY() which takes a and b as input parameters and returns the least possible values of x and y to satisfy the equation.
Expected Time Complexity: O(log(max(a, b)))
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ a, b ≤ 10^{4}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def findXY(self, a, b):

        # code here

Solutions:
class Solution:

	def findXY(self, a, b):
		import math
		n = math.gcd(a, b)
		x = a / n
		y = b / n
		if b / a == y / x:
			return [int(y), int(x)]


class Solution:

	def findXY(self, a, b):
		i = 2
		n = min(a, b)
		while i != n + 1:
			if a % i == 0 and b % i == 0:
				a = a // i
				b = b // i
			else:
				i += 1
		return (b, a)


class Solution:

	def findXY(self, a, b):

		def gcd(m, n):
			if n == 0:
				return m
			return gcd(n, m % n)
		result = a * b // gcd(a, b)
		x = result // a
		y = result // b
		return (x, y)


import math

class Solution:

	def findXY(self, a, b):
		l = math.gcd(a, b)
		return [b // l, a // l]


class Solution:

	def findXY(self, a, b):
		if a > b:
			greater = a
		else:
			greater = b
		while True:
			if greater % a == 0 and greater % b == 0:
				lcm = greater
				break
			greater += 1
		return (lcm // a, lcm // b)


from math import gcd

class Solution:

	def findXY(self, a, b):
		m = gcd(a, b)
		l = []
		l.append(b // m)
		l.append(a // m)
		return l


class Solution:

	def findXY(self, a, b):
		p = max(a, b)
		q = min(a, b)
		for i in range(1, q + 1):
			if p * i % q == 0:
				break
		j = int(p * i / q)
		if p == a:
			return [i, j]
		else:
			return [j, i]


class Solution:

	def findXY(self, a, b):
		r = [0] * 2
		if a > b:
			small = b
		else:
			small = a
		for i in range(1, small + 1):
			if a % i == 0 and b % i == 0:
				gcd = i
		lcm = a * b // gcd
		r[0] = lcm // a
		r[1] = lcm // b
		return r


import math

class Solution:

	def findXY(self, a, b):
		h = math.gcd(a, b)
		l = a / h * b
		arr = []
		a1 = l / a
		arr.append(int(a1))
		a2 = l / b
		arr.append(int(a2))
		return arr