#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
if(!a) return b;
return gcd(b % a, a);
}
ll lcm(ll a, ll b) {
return a * b / gcd(a, b);
}
int main() {
cout << gcd(12, 18) << endl;
cout << gcd(0, 18) << endl;
cout << lcm(12, 18) << endl;
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter