A Math Contest P7 - Factors

View as PDF

Submit solution

Points: 10
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

Define f(x) as the number of factors of a positive integer x. Given an integer N, determine i=1Nf(i).

Input Specification

The only line contains an integer, N (1N1012).

Output Specification

Output the value of i=1Nf(i).

Sample Input

Copy
5

Sample Output

Copy
10

Explanation for Sample

1 has 1 factor: 1.

2 has 2 factors: 1 and 2.

3 has 2 factors: 1 and 3.

4 has 3 factors: 1, 2, and 4.

5 has 2 factors: 1 and 5.

i=1Nf(i)=1+2+2+3+2=10


Comments


  • -2
    RVMIA  commented on April 1, 2023, 1:29 a.m.

    TLE with haskell :(


    • 2
      dnialh_  commented on April 1, 2023, 4:58 p.m.

      Haskell lazy evaluation isn't magic, directly factoring each of the 1012 numbers must take at least 1012 operations and will always be too slow.