The G.C.D. of two numbers is 25% of one of the numbers. The second
number is 9 times the G.C.D. If sum of the numbers is 1625 find those
numbers.
Answers
Step-by-step explanation:
Let f(n, x) be a function which gives a number n repeated x times. So, we need to find GCD(f(n, x), f(n, y)).
Let n = 123, x = 3, y = 2.
So, first number A is f(123, 3) = 123123123 and second number B is f(123, 2) = 123123. We know, GCD(A,B) = GCD(A – B, B), using this property we can subtract any multiple of B, say B’ from first A as long as B’ is smaller than A.
So, A = 123123123 and B’ can be 123123000. On subtracting A will became 123 and B remains same.
Therfore, A = A – B’ = f(n, x – y).
So, GCD(f(n, x), f(n, y)) = GCD(f(n, x – y), f(n, y))
We can conclude following,
GCD(f(n, x), f(n, y)) = f(n, GCD(x, y)).
Below is the implementation based on this approach:
CPP
// C++ program to print Greatest Common Divisor
// of number formed by N repeating x times and
// y times.
#include<bits/stdc++.h>
using namespace std;
// Return the Greatest common Divisor of two numbers.
int gcd(int a, int b)
{
if (a == 0)
return b;
return gcd(b%a, a);
}
// Prints Greatest Common Divisor of number formed
// by n repeating x times and y times.
Answer:
it will be 55
Step-by-step explanation: