TopCoder problem "EratosthenSieve2" used in SRM 296 (Division II Level One)



Problem Statement

    

Let N1 = {1, 2, 3, 4, 5, ..., 1000} (the set of all positive integers between 1 and 1000, inclusive).

Delete every second number in N1. The result is N2 = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, ..., 999}.

Delete every third number in N2. The result is N3 = {1, 3, 7, 9, 13, 15, 19, 21, 25, ..., 999}.

Delete every fourth number in N3. The result is N4 = {1, 3, 7, 13, 15, 19, 25, 27, ...}.

...

Delete every tenth number in N9. The result is N10. Find and return the n-th element of sequence N10, where n is a 1-based index.

 

Definition

    
Class:EratosthenSieve2
Method:nthElement
Parameters:int
Returns:int
Method signature:int nthElement(int n)
(be sure your method is public)
    
 

Notes

-N10 will contain exactly 101 elements.
 

Constraints

-n will be between 1 and 100, inclusive.
 

Examples

0)
    
3
Returns: 7
1)
    
1
Returns: 1
2)
    
10
Returns: 79
3)
    
25
Returns: 223

Problem url:

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

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=9817&pm=6084

Writer:

Mike Mirzayanov

Testers:

PabloGilberto , brett1479 , radeye , Olexiy

Problem categories:

Brute Force