From 5ab8a5088b729a9953b8dff1b2a985dc8fb2098b Mon Sep 17 00:00:00 2001 From: mzuenni Date: Mon, 27 Jun 2022 17:19:28 +0200 Subject: updated tcr --- math/divisors.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 math/divisors.cpp (limited to 'math/divisors.cpp') diff --git a/math/divisors.cpp b/math/divisors.cpp new file mode 100644 index 0000000..638c87c --- /dev/null +++ b/math/divisors.cpp @@ -0,0 +1,11 @@ +ll countDivisors(ll n) { + ll res = 1; + for (ll i = 2; i * i * i <= n; i++) { + ll c = 0; + while (n % i == 0) {n /= i; c++;} + res *= c + 1; + } + if (isPrime(n)) res *= 2; + else if (n > 1) res *= isSquare(n) ? 3 : 4; + return res; +} \ No newline at end of file -- cgit v1.2.3