diff --git a/Task 1/Find the constant value in ax + by = c./Find the constant value in ax + by = c.md b/Task 1/Find the constant value in ax + by = c./Find the constant value in ax + by = c.md new file mode 100644 index 00000000..cd3834e2 --- /dev/null +++ b/Task 1/Find the constant value in ax + by = c./Find the constant value in ax + by = c.md @@ -0,0 +1,19 @@ +# Find the constant value for a linear two variable equation i.e., ax + by = c. + +- a & b are given, you need to find the constant 'c' value, how you find it with two independent variables? And x,y can be integers, rational number, etc. +- Let's take few Examples: +
+ 25x + 10y = c, + 10x + 100y = c, + 11x + 35y = c ++ +# Solution: + +- Extended Euclidean Algorithm is one of such algorithm which help to find solutions of such problems. How? +- Extended Euclidean stated as: +
+ ax + by = gcd(a, b) ++- So, it becomes finding the gcd of two numbers and the problem solved. +- Check the Solution.py file for the solution. diff --git a/Task 1/Find the constant value in ax + by = c./Solution.py b/Task 1/Find the constant value in ax + by = c./Solution.py new file mode 100644 index 00000000..4a88d8d1 --- /dev/null +++ b/Task 1/Find the constant value in ax + by = c./Solution.py @@ -0,0 +1,17 @@ +# Here you will find the solution in python language + +# Given two numbers in the form of equation: + +# GCD function: +def GCD(a, b): + if a == 0: + return b + return GCD(b, a%b) + + +a,b = 5, 10 +# Call GCD +result = GCD(a, b) +print(result) + +# result is constnat value.