algorithm

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

View the Project on GitHub gtnao/algorithm

:heavy_check_mark: src/math/is_prime.hpp

Verified with

Code

#pragma once

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

template <typename T = long long> bool is_prime(T n) {
  for (T i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
#line 2 "src/math/is_prime.hpp"

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

template <typename T = long long> bool is_prime(T n) {
  for (T i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
Back to top page