This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub ruthen71/rcpl
#include "math/totient_table.hpp"
#pragma once std::vector<int> totient_table(int n) { std::vector<int> res(n + 1); std::iota(res.begin(), res.end(), 0); for (int p = 2; p <= n; p++) { if (res[p] != p) continue; for (int i = p; i <= n; i += p) { res[i] /= p; res[i] *= p - 1; } } return res; }
#line 2 "math/totient_table.hpp" std::vector<int> totient_table(int n) { std::vector<int> res(n + 1); std::iota(res.begin(), res.end(), 0); for (int p = 2; p <= n; p++) { if (res[p] != p) continue; for (int i = p; i <= n; i += p) { res[i] /= p; res[i] *= p - 1; } } return res; }