lmori's Library

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub lmorinn/library

:heavy_check_mark: Euler's Phi Function Table
(math/number-theory/EulersPhiFunctionTable.hpp)

概要

todo

計算量

todo

Verified with

Code

vector<int> Eulers_phi_function_table(int n) {
  vector<int> table(n + 1);
  iota(table.begin(), table.end(), 0);

  for (int i = 2; i <= n; i++) {
    if (table[i] == i) {
      for (int j = i; j <= n; j += i) {
        table[j] = table[j] / i * (i - 1);
      }
    }
  }
  return table;
}
#line 1 "math/number-theory/EulersPhiFunctionTable.hpp"
vector<int> Eulers_phi_function_table(int n) {
  vector<int> table(n + 1);
  iota(table.begin(), table.end(), 0);

  for (int i = 2; i <= n; i++) {
    if (table[i] == i) {
      for (int j = i; j <= n; j += i) {
        table[j] = table[j] / i * (i - 1);
      }
    }
  }
  return table;
}
Back to top page