kyopro-lib

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

View on GitHub

:heavy_check_mark: Primality test (Trial division)
(Mylib/Number/Prime/is_prime.cpp)

Operations

Requirements

Notes

Problems

References

Verified with

Code

#pragma once

namespace haar_lib {
  constexpr bool is_prime(int n) {
    if (n <= 1) return false;
    for (int i = 2; i * i <= n; ++i) {
      if (n % i == 0) return false;
    }
    return true;
  }
}  // namespace haar_lib
#line 2 "Mylib/Number/Prime/is_prime.cpp"

namespace haar_lib {
  constexpr bool is_prime(int n) {
    if (n <= 1) return false;
    for (int i = 2; i * i <= n; ++i) {
      if (n % i == 0) return false;
    }
    return true;
  }
}  // namespace haar_lib
Back to top page