Skip to content

Commit e67222a

Browse files
committed
add naive divisor enumerator to factorize.hpp
1 parent 060ad03 commit e67222a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cp-algo/number_theory/factorize.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,16 @@ namespace cp_algo::math {
4343
co_yield std::ranges::elements_of(factorize(m / g));
4444
}
4545
}
46+
template<typename Int>
47+
std::generator<Int> divisors_sqrt(Int m) {
48+
for(Int i = 1; i * i <= m; i++) {
49+
if(m % i == 0) {
50+
co_yield i;
51+
if(i * i != m) {
52+
co_yield m / i;
53+
}
54+
}
55+
}
56+
}
4657
}
4758
#endif // CP_ALGO_MATH_FACTORIZE_HPP

0 commit comments

Comments
 (0)