diff --git a/seminar04_templates/03_factorization/main.cpp b/seminar04_templates/03_factorization/main.cpp index fde4487..990b5eb 100644 --- a/seminar04_templates/03_factorization/main.cpp +++ b/seminar04_templates/03_factorization/main.cpp @@ -5,8 +5,6 @@ using std::cout, std::endl, std::pair, std::vector; -int next_prime(int n); - vector> factorization(int n) { if (n == 1) { return vector>{{1, 1}}; @@ -23,31 +21,11 @@ vector> factorization(int n) { } if (c) result.push_back(pair{d, c}); - d = next_prime(d); + d++; } return result; } -bool is_prime(int n) { - bool prime = true; - for(int i = 2; i <= static_cast(std::sqrt(n)); i++) { - if (n % i == 0) { - prime = false; - break; - } - } - return prime; -} - -int next_prime(int n) { - ++n; - while (true) { - if (is_prime(n)) - return n; - ++n; - } -} - std::ostream& operator<<(std::ostream& out, pair p) { out << "{" << p.first << ", " << p.second << "}"; return out;