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)

import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {
  val MOD = 1000000007
  def solve(N: Int): Long = {
    val f = {
      val f: ArrayBuffer[Int] = ArrayBuffer.empty
      for {
        i <- 1 to N
      } f ++= factorize(i)
      f.sorted
    }

    var res: Long = 1
    var i = 0
    while(i < f.length) {
      var j = i
      while (j < f.length && f(i) == f(j)) j += 1
      val len = j - i
      res = res * (len + 1) % MOD
      i = j
    }

    res
  }

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    println(solve(sc.nextInt()))
  }

  def factorize(n: Int): Array[Int] = {
    // 見つからなかったら-1
    def minFactor(n0: Int, i: Int): Int = {
      if (i > n0) -1
      else if (n0 % i == 0) i
      else minFactor(n0, i + 1)
    }

    def step(n0: Int, acc: List[Int]): List[Int] = {
      minFactor(n0, 2) match {
        case -1 => acc
        case f => step(n0 / f, f :: acc)
      }
    }

    step(n, Nil).toArray
  }
}