algorithm

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub gtnao/algorithm

:heavy_check_mark: src/math/lcm.hpp

Depends on

Verified with

Code

#pragma once

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

#include "gcd.hpp"

template <typename T = long long> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#line 2 "src/math/lcm.hpp"

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

#line 2 "src/math/gcd.hpp"

#line 4 "src/math/gcd.hpp"
using namespace std;

template <typename T = long long> T gcd(T a, T b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
#line 7 "src/math/lcm.hpp"

template <typename T = long long> T lcm(T a, T b) { return a / gcd(a, b) * b; }
Back to top page