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
7
Returns: 21
f(1)+f(2)+f(3)+f(4)+f(5)+f(6)+f(7)=1+1+3+1+5+3+7=211
Returns: 1
777
Returns: 201537