Problem 187783 · easy · Phase 01 Prerequisites & Setup

How Many Divisors?

functions · loops · modulo

Write a function count_divisors(n) that returns how many positive integers divide n exactly.

For example, 12 is divisible by 1, 2, 3, 4, 6, 12, so the answer is 6.

Examples

Input:  n = 12
Output: 6

Input:  n = 7
Output: 2

Constraints

  • 1 <= n <= 10**9
  • Your function must finish quickly even for the largest n.

Goals

  • Use `%` to test divisibility
  • Avoid checking every number up to `n`
Starting Python…