kyopro-lib

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

View on GitHub

:warning: Greatest common divisor / Least common multiple
(Mylib/Number/gcd_lcm.cpp)

Operations

Requirements

Notes

Problems

References

Code

#pragma once
#include <cstdint>
#include <utility>

namespace haar_lib {
  int64_t gcd(int64_t a, int64_t b) {
    if (a < b) std::swap(a, b);
    if (b == 0) return a;

    return gcd(b, a % b);
  }

  int64_t lcm(int64_t a, int64_t b) {
    return a / gcd(a, b) * b;
  }
}  // namespace haar_lib
#line 2 "Mylib/Number/gcd_lcm.cpp"
#include <cstdint>
#include <utility>

namespace haar_lib {
  int64_t gcd(int64_t a, int64_t b) {
    if (a < b) std::swap(a, b);
    if (b == 0) return a;

    return gcd(b, a % b);
  }

  int64_t lcm(int64_t a, int64_t b) {
    return a / gcd(a, b) * b;
  }
}  // namespace haar_lib
Back to top page