1
2// https://www.geeksforgeeks.org/count-divisors-n-on13/
3int countDivisors(int n) {
4 int cnt = 0;
5 for (int i = 1; i <= sqrt(n); i++) {
6 if (n % i == 0) {
7 // If divisors are equal,
8 // count only one
9 if (n / i == i)
10 cnt++;
11
12 else // Otherwise count both
13 cnt = cnt + 2;
14 }
15 }
16 return cnt;
17}