Computer Science, asked by Annapragadasravya99, 9 months ago

You are given three numbers a,b,c write a program to determine the largest number that is less than or equal to c and leaves a remainder b when divided by a

Answers

Answered by gautamsaugatimt
0

Answer:

--

Explanation:

Answered by KajalBarad
0

// three sorted numbers

#include <bits/stdc++.h>

using namespace std;

//__gcd function

int gcd(int a, int b)

{

if (a == 0)

return b;

return gcd(b % a, a);

}

// function return number which divides these

// three number and leaves same remainder .

int sameRemainder(int a, int b, int c)

{

// We find the differences of all three pairs

int a1 = (b - a), b1 = (c - b), c1 = (c - a);

// Return GCD of three differences.

return gcd(a1, gcd(b1, c1));

}

// driver program

int main()

{

int a = 62, b = 132, c = 237;

cout << sameRemainder(a, b, c) << endl;

return 0;

}

Similar questions