Problem Statement
The function g(n, p) is defined for all positive integers n and all primes p. Its definition is as follows:
if n is not divisible by p:
g(n,p) = 0
otherwise:
g(n,p) = the largest power of p that does not exceed n
The function f(n) is defined for all positive integers as follows: f(n) is the sum of g(n,p) over all primes p.
You are given an int X. Compute and return the exact value of the sum f(1) + f(2) + ... + f(X).
Definition
- Class:
- SimpleMathProblemDiv1
- Method:
- calculate
- Parameters:
- long
- Returns:
- long
- Method signature:
- long calculate(long X)
- (be sure your method is public)
Notes
- You may assume that the largest possible output fits into a long.
Constraints
- X will be between 1 and 3,333,377,777, inclusive.
Examples
1
Returns: 0
8
Returns: 36
15
Returns: 128
777444111
Returns: 342683738130575177