I am trying to find a faster lcm function than I currently have. I tried to look up some better gcd but couldn't find anything that solves the problem.
#include <bits/stdc++.h>
const int MOD = 1000000007;
using namespace std;
long gcd (long a, long b)
{
if (a == 0) return b;
return gcd (b % a, a);
}
long lcm (long a, long b)
{
if (a == 0 || b == 0) return 0;
return a * b / gcd (a, b);
}