TopCoder problem "
OddDivisors
" used in SRM 449 (Division II Level Two)
Problem Statement
Let f(x) be the greatest odd divisor of x, where x is a positive integer. You are given a positive integer
N
. Return f(1)+f(2)+?+f(
N
).
Definition
Class:
OddDivisors
Method:
findSum
Parameters:
int
Returns:
long
Method signature:
long findSum(int N)
(be sure your method is public)
Constraints
-
N
will be between 1 and 1000000000, inclusive.
Examples
0)
7
Returns: 21
f(1)+f(2)+f(3)+f(4)+f(5)+f(6)+f(7)=1+1+3+1+5+3+7=21
1)
1
Returns: 1
2)
777
Returns: 201537
Problem url:
http://www.topcoder.com/stat?c=problem_statement&pm=10547
Problem stats url:
http://www.topcoder.com/tc?module=ProblemDetail&rd=13903&pm=10547
Writer:
dzhulgakov
Testers:
PabloGilberto , ivan_metelsky , zhuzeyuan
Problem categories:
Recursion, Simple Math