TopCoder problem "SquareFreeNumbers" used in TCO09 Qual 1 (Division I Level Two)



Problem Statement

    A number is called square-free if it is not divisible by a perfect square which is greater than one. A perfect square is the square of an integer. Return the number of square-free numbers between min and max, inclusive.
 

Definition

    
Class:SquareFreeNumbers
Method:getCount
Parameters:long, long
Returns:int
Method signature:int getCount(long min, long max)
(be sure your method is public)
    
 

Constraints

-min will be between 1 and 1,000,000,000,000, inclusive.
-max will be between min and (min + 1,000,000), inclusive.
 

Examples

0)
    
1
10
Returns: 7
Numbers 4, 8 and 9 are not square-free.
1)
    
15
15
Returns: 1
min and max can be equal.
2)
    
1
1000
Returns: 608

Problem url:

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

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=13742&pm=8004

Writer:

FedorTsarev

Testers:

PabloGilberto , legakis , Olexiy , ivan_metelsky

Problem categories:

Math