Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- // euclidian algorithm
- unsigned gcd(unsigned u, unsigned v)
- {
- while (v != 0)
- {
- unsigned r = u % v;
- u = v;
- v = r;
- }
- return u;
- }
- // ab = (a, b)[a, b]
- // [a, b] = ab / (a, b)
- unsigned lcm(unsigned u, unsigned v)
- {
- return (u / gcd(u, v)) * v;
- }
- int main()
- {
- int a, b, c;
- cin >> a >> b >> c;
- cout << gcd(gcd(a, b), c) << endl;
- cout << lcm(lcm(a, b), c) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement