This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub kmyk/competitive-programming-library
#include "number/gcd.hpp"
#pragma once
#include <algorithm>
/**
* @note if arguments are negative, the result may be negative
*/
template <typename T>
T gcd(T a, T b) {
while (a) {
b %= a;
std::swap(a, b);
}
return b;
}
template <typename T>
T lcm(T a, T b) {
return a / gcd(a, b) * b;
}
#line 2 "number/gcd.hpp"
#include <algorithm>
/**
* @note if arguments are negative, the result may be negative
*/
template <typename T>
T gcd(T a, T b) {
while (a) {
b %= a;
std::swap(a, b);
}
return b;
}
template <typename T>
T lcm(T a, T b) {
return a / gcd(a, b) * b;
}