Problem:
Score : 300 points

Problem Statement

You are given an integer N.
Find the number of the positive divisors of N!, modulo 10^9+7.

Constraints

1≤N≤10^3

Input

The input is given from Standard Input in the following format:

N

Output

Print the number of the positive divisors of N!, modulo 10^9+7.

Sample Input 1

3

Sample Output 1

4

There are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.

Sample Input 2

6

Sample Output 2

30

Sample Input 3

1000

Sample Output 3

972926972

Solution in Kotlin (1.0.0) (judge verdict: Accepted)

fun main(args: Array<String>) {
    arc067a()
}

fun arc067a() {
    val n = readLine()!!.toLong()

    if (n == 1L) return println(1)

    val answer = (2..n).map { primeFactorization(it).toList() }.flatten()
        .groupBy { it.first }.map { entry -> entry.value.map { it.second }.sum() }
        .fold(1L) { acc, l -> mod(acc * (l + 1)) }

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()
private fun mod(x: Long): Long = x % MOD

private fun primeFactorization(n: Long): Map<Long, Long> {
    val factors = mutableMapOf<Long, Long>()
    var temp = n
    var i = 2L
    while (i * i <= temp) {
        while (temp % i == 0L) {
            factors[i] = (factors[i] ?: 0) + 1
            temp /= i
        }
        i++
    }
    if (temp > 1) factors[temp] = 1
    return factors
}