Skip to content

Latest commit

 

History

History
22 lines (21 loc) · 3.66 KB

57-find-divisors-of-a-number.md

File metadata and controls

22 lines (21 loc) · 3.66 KB

Problem:

Find the number of divisors of a positive integer n.

Random tests go up to n = 500000.

Examples

divisors 4  = 3 -- 1, 2, 4
divisors 5  = 2 -- 1, 5
divisors 12 = 6 -- 1, 2, 3, 4, 6, 12
divisors 30 = 8 -- 1, 2, 3, 5, 6, 10, 15, 30
divisors(4)  = 3  # 1, 2, 4
divisors(5)  = 2  # 1, 5
divisors(12) = 6  # 1, 2, 3, 4, 6, 12
divisors(30) = 8  # 1, 2, 3, 5, 6, 10, 15, 30
divisors(4) -> 3 -- 1, 2, 4
divisors(5) -> 2 -- 1, 5
divisors(12) -> 6 -- 1, 2, 3, 4, 6, 12
divisors(30) -> 8 -- 1, 2, 3, 5, 6, 10, 15, 30
Kata.Divisors(4) -> 3 -- 1, 2, 4
Kata.Divisors(5) -> 2 -- 1, 5
Kata.Divisors(12) -> 6 -- 1, 2, 3, 4, 6, 12
Kata.Divisors(30) -> 8 -- 1, 2, 3, 5, 6, 10, 15, 30

Solution