Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int LargestCommonDivisor(int a, int b)
- {
- while (a > 0)
- {
- if (b > a)
- {
- int Temp = a;
- a = b;
- b = Temp;
- }
- a = a - b;
- }
- return b;
- }
- int main()
- {
- int a, b, LCD;
- scanf("%d/%d", &a, &b);
- LCD = LargestCommonDivisor(a,b);
- printf("%d/%d\n", LCD, b/LCD);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment