Code Room
CodingMediumcod-g168
Subject Number theoryLevel Mid–Senior~18 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Given a positive integer n (1 <= n <= 10^12), return the number of positive divisors of n, including 1 and n itself. For example, 12 has divisors 1, 2, 3, 4, 6, 12, so the answer is 6. The value of n can be large enough that listing every candidate up to n is too slow.

Implement
count_divisors(n: int) → int
Examples
in[12]out6
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.