GCD, LCM

PHOTO EMBED

Tue Aug 27 2024 18:38:51 GMT+0000 (Coordinated Universal Time)

Saved by @LizzyTheCatto

#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
using namespace std;


int gcd(int a, int b){
    while(b != 0) {
        int temp = b;
        b = a % b;
        a = temp;
    }
    return a;
}

int lcm(int a, int b){
    return (a*b) / gcd(a,b);
}
content_copyCOPY

https://www.programiz.com/cpp-programming/online-compiler/