TopCoder problem "ProperDivisors" used in SRM 394 (Division II Level Three)



Problem Statement

    An integer k greater than 0 is called a cool divisor of m if it is less than m and divides m, but k^n does not divide m. Let d(m) denote the number of cool divisors that exist for an integer m. Given two integers a and b return the sum d(a) + d(a + 1) + ... + d(a + b).
 

Definition

    
Class:ProperDivisors
Method:analyzeInterval
Parameters:int, int, int
Returns:int
Method signature:int analyzeInterval(int a, int b, int n)
(be sure your method is public)
    
 

Notes

-The result will always fit into a signed 32-bit integer.
 

Constraints

-a will be between 1 and 1000000 (10^6), inclusive.
-b will be between 1 and 10000000 (10^7), inclusive.
-n will be between 2 and 10, inclusive.
 

Examples

0)
    
32
1
3
Returns: 5
The cool divisors of 32 are 4, 8 and 16 so d(32) = 3; the cool divisors of 33 are 3 and 11 so d(33) = 2. Hence the desired sum d(32) + d(33) = 3 + 2 = 5.
1)
    
1
12
2
Returns: 8
2)
    
1000000
10000000
10
Returns: 146066338

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=8547

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=11128&pm=8547

Writer:

Xixas

Testers:

PabloGilberto , Olexiy , marek.cygan , ivan_metelsky

Problem categories:

Math, Simple Search, Iteration