Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("test.in");
- ofstream fout("test.out");
- int cmm_factor_prim(int n) {
- int div = -1, mult6 = 6;
- while (mult6 - 1 <= n) {
- if (n % (mult6 - 1) == 0) {
- div = mult6 - 1;
- n /= div;
- }
- if (n % (mult6 + 1) == 0) {
- div = mult6 + 1;
- n /= div;
- }
- mult6 += 6;
- }
- return n;
- }
- int main() {
- int n;
- fin >> n;
- fout << cmm_factor_prim(n) << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement