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 Scala (2.11.7) (judge verdict: Accepted)

object Main extends App {
  val primes: Stream[Int] = Stream.cons(2, Stream.from(3, 2) filter { i =>
    (i > 1) && primes.takeWhile(_ <= Math.sqrt(i)).forall(i % _ != 0)
  })

  def primeFactorization(n: Int): List[(Int, Int)] =
    primeFactorization(n, primes)

  def primeFactorization(n: Int, primes: Stream[Int]): List[(Int, Int)] = {
    if (n == 1) List.empty
    else {
      val (count, vn) = trialDivision(n, primes.head, 0)
      if (count == 0) primeFactorization(vn, primes.tail)
      else (primes.head, count) :: primeFactorization(vn, primes.tail)
    }
  }

  def trialDivision(n: Int, p: Int, e: Int): (Int, Int) = {
    if (n % p != 0) (e, n)
    else trialDivision(n / p, p, e + 1)
  }

  val n = io.StdIn.readInt
  var map = Map.empty[Int, Int]
  for (i <- 2 to n) {
    primeFactorization(i).toMap.foreach(t => {
      val v = map.getOrElse(t._1, 0)
      map = map + (t._1 -> (v + t._2))
    })
  }
  println(map.foldLeft(1L) { (acc, t) =>
    (acc * (t._2 + 1L)) % 1000000007L
  })
}