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


object Main extends App  {
  val sc = new Scanner(System.in)

  val n = sc.nextInt

  val primeList = (1 to n).filter(isPrime)

  val primeDecompositionList = (2 to n).map{ k =>
    val eachList =
      k match {
        case 1 => List(1)
        case x =>loop(x)
      }
    loop2(eachList,List.empty[(Int,Int)])
  }

  val res = primeDecompositionList.flatten.groupBy(_._1).values.foldLeft(1L){ (prod, list) =>
    prod * ( list.map(_._2).sum + 1) % 1000000007
  }

  println(res)

  def isPrime(num: Int) :Boolean={
    num match{
      case 1 => false
      case 2 => true
      case x => (2 to Math.sqrt(x).floor.toInt).forall(x % _ != 0)
    }
  }

  def loop(num: Int): List[Int] ={
    num match{
      case 1 => List(1)
      case x if primeList.contains(x) => List(x)
      case x => {
        val z = primeList.find(x % _ == 0).get
        z +: loop(x / z)
      }
    }
  }

  def loop2(list: List[Int], ll: List[(Int,Int)]): List[(Int,Int)]={
    if(list.isEmpty) ll
    else {
      val (t, f) = list.partition(_ == list.head)
      loop2(f, ll :+ (t.head, t.size) )
    }
  }
}