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 (Python):
dissembly = {}
def factoring(N):
	from math import sqrt
	global dissembly
	search_maxval = sqrt(N) + 1
	i = 2
	while True:
		if N == 1 or i == search_maxval:
			break

		if N % i == 0:
			if i in dissembly:
				dissembly[i] += 1
			else:
				dissembly[i] = 1

			N /= i

		else:
			i += 1


n = int(input())
ans = 1
for i in range(2,n+1):
	factoring(i)


for val in dissembly.values():
	ans *= (val+1)
	ans %= ((10 ** 9) + 7)

print(ans)

Solution (Python):
N = int(input())
div = 10**9+7



def mark(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False


def eratosthenes(n):
    s = [True] * n
    for x in range(2, int(n ** 0.5) + 1):
        if s[x]: mark(s, x)
    return [i for i in range(0, n) if s[i] and i > 1]


primes = eratosthenes(1000)
num_pow = [1] * (N+1)

for n in range(1, N+1):
    for p in primes:
        if p > n:
            break
        while True:
            if n % p == 0:
                n /= p
                num_pow[p] += 1
            else:
                break

ans = 1
for z in num_pow:
    ans *= z

print(ans % div)

Solution (Python):
def prime_decomposition(n):
    
    from collections import defaultdict
    i = 2
    table = defaultdict(int)
    while i**2 <= n:
        while n % i == 0:
            n //= i
            table[i]+=1
        i += 1
    if n > 1:
        table[n]+=1
    return table

import math
N = int(input())
c = prime_decomposition(math.factorial(N))
ans = 1
for k, v in c.items():
    ans = (ans * (v + 1)) % (10**9 + 7)
print(ans)

Solution (Python):
n = int(input())
ps = [0] * (n + 1)
for i in range(2, n + 1):
    x = i
    p = 2
    while x > 1:
        while x % p == 0:
            ps[p] += 1
            x //= p
        p += 1
ans = 1
for c in ps:
    ans = (ans * (c + 1)) % 1000000007
print (ans)

Solution (Python):
from collections import Counter


def main():
    """
    1 <= N <= 10 ** 3
    N! の正の約数の個数を10**9+7 で割った余り

    (10 ** 3)! => loopじゃ無理

    1000 * 999 * 998 * ... * 2 * 1
    →それぞれの約数を求める(1000以下なので問題なし)

    素因数分解:
    e.g. 72
        2^3 * 3^2 * 1 => 6つの要素
        6C1,6C2,6C3,6C4,6C5,6C6
        重複除外(どうする) => 6C2: 2_1,2_2と2_2,2_3

        71についても同様かつ、72の約数との組合せ => 膨大な数になる

    解説:
    ある整数 x が、素因数分解によって x = p^n × q^m × ... (p, q, ...は素数) と表せる時、
    x の約数の個数は(n + 1) × (m + 1) × ... となります。
    """
    N = int(input())

    if N == 1:
        print(1)
        return

    table = eratosthenes(N)
    factors = Counter()
    for i in range(2, N + 1):
        factors += factorize(i, table)

    ans = 1
    for count in factors.values():
        ans = ans * (count + 1) % (10 ** 9 + 7)
    print(ans)


def factorize(N, table):
    factors = Counter()
    x = N
    for i in [2] + list(range(3, N + 1, 2)):
        if table[i]:
            while x % i == 0:
                if i in factors:
                    factors[i] += 1
                else:
                    factors[i] = 1
                x = x // i

    return factors


def eratosthenes(N):
    a = [True for _ in range(N + 1)]
    a[0] = False
    a[1] = False

    for i in range(2, N + 1):
        if a[i]:
            for j in range(i + 1, N + 1):
                if j % i == 0:
                    a[j] = False

    return a

if __name__ == '__main__':
    main()

Solution (Python):
import collections
N=input()

a=[]
def soinsu_bunkai(x):
	if x==1:
		a.append(1)
		return a
	n=x
	flag=0
	while flag!=1:
		for i in range(2,x+1):
			if n%i==0:
				n=n/i
				if n==1:
					flag=1
				
				a.append(i)
				break
	return a


for i in range(2,N+1):
	soinsu_bunkai(i)



b=collections.Counter(a)


ans=1
for i in b.values():
	ans*=(i+1)

print ans%(10**9+7)

Solution (Python):
import math


def get_prime_list(n):
    prime = [2]
    for i in range(3, n+1):
        flag = True
        for j in range(2, i):
            if i%j == 0:
                flag = False
                break
        if flag:
            prime.append(i)
    return prime


def main():
    n = int(input())

    prime = get_prime_list(n)
    d = dict()
    for i in prime:
        cnt = 0
        for j in range(2, n+1):
            while j>1:
                if j%i == 0:
                    cnt += 1
                    j //= i
                else:
                    j = 0
        d[i] = cnt

    ans = 1
    for key, value in d.items():
        if value != 0:
            ans = ans * (value+1) % (10**9+7)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import math


def prime(n):
    p = list(range(n+1))
    p[1] = 0

    for x in p:
        if x == 0:
            continue
        if x > math.sqrt(n):
            break
        for y in range(2 * x, n+1, x):
            p[y] = 0

    return [x for x in p if x != 0]


n = int(input())

p = prime(n)
a = [1] * len(p)

for i in range(1, n+1):
    for j in range(len(p)):
        while i % p[j] == 0:
            a[j] += 1
            i //= p[j]

ans = 1

for x in a:
    ans = ans * x % (10**9+7)

print(ans)

Solution (Python):
import math

N = int(input())
gc = [0] * (N + 1)
ans = 1


def solve(n):
    num = 2
    while num <= n:
        while int(n % num) is 0:
            n /= num
            gc[num] += 1
        num += 1
        if n is 1:
            break
    return 0


for i in range(1, N + 1):
    solve(i)
for p in gc:
    if p is not 0:
        ans *= p + 1
print(ans % (10 ** 9 + 7))

Solution (Python):
n=int(input())
mod=10**9+7
ans=1
from math import factorial
f=factorial(n)
p=[2]
for i in range(2,1001):
    flag=0
    for j in p:
        if i%j==0:
            flag=1
            break
    if flag==1:
        continue
    p.append(i)
for i in p:
    k=0
    while f%i**k==0:
        k+=1
    ans=ans*k
print(ans%mod)

Solution (Python):
from collections import defaultdict

MOD = 10 ** 9 + 7



def prime_factor_decomposition(n):
    import math
    m = defaultdict(int)
    while n > 1:
        find_factor = False
        for i in range(2, int(math.sqrt(n)) + 1):

            if n % i == 0:
                m[i] += 1
                n //= i
                find_factor = True
                break

        if not find_factor:
            m[n] += 1
            break

    return m


def main():
    N = int(input())
    m = defaultdict(int)
    for i in range(1, N + 1):
        d = prime_factor_decomposition(i)
        for k, v in d.items():
            m[k] += v
    ans = 1
    for k, v in m.items():
        ans = (ans * (v + 1)) % MOD

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import sys



M = 10 ** 9 + 7


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def is_prime(n):
    for d in range(2, n - 1):
        if n % d == 0:
            return False
    return True


def main():
    n = read_int()
    res = 1
    for p in range(2, n + 1):
        if is_prime(p):
            np = 0
            for i in range(1, n + 1):
                j = i
                while j % p == 0:
                    j //= p
                    np += 1
            res *= np + 1
            res %= M
    print(res)


main()

Solution (Python):
from collections import Counter
import math

N = input()
PRIMES = [2,3,5,7,11,13,17,19,23,27,29,31] 
factors = []
for n in range(2,N+1):
  tmp = n
  for prime in PRIMES:
    while tmp % prime == 0:
      factors.append(prime)
      tmp /= prime
    if tmp == 1:
      break
  if tmp > math.sqrt(n):
    factors.append(tmp)

count = 1
for v in Counter(factors).values():
  count *= (v+1)
count = count % (10**9+7)
print count

Solution (Python):
n = int(input())
MOD = 10**9 + 7

p = [True for i in range(n+1)]
ret = 1
for i in range(2, n+1):
    if not p[i]:
        continue
    for j in range(n//i + 1):
        p[i*j] = False
    j = 1
    cnt = 1
    while i**j <= n:
        cnt += n//(i**j)
        j += 1
    ret = (ret * cnt) % MOD
print(ret)

Solution (Python):
is_prime = [True for i in range(10**3+1)]
is_prime[0] = is_prime[1] = False
primes = []
for i in range(2, len(is_prime)):
    if is_prime[i]:
        primes.append(i)
        for j in range(i*2, len(is_prime), i):
            is_prime[j] = False

prime_num_mapping = {p: 0 for p in primes}
def count(x):
    for p in primes:
        while x % p == 0:
            prime_num_mapping[p] += 1
            x /= p
        if x == 1:
            break
ans = 1
N = int(raw_input())
for x in range(N, 0, -1):
    count(x)
for k, v in prime_num_mapping.items():
    ans = (ans * (v+1)) % (10**9+7)
print ans

Solution (Python):
N=int(input())
R=[0]*(N-1)
for i in range(1,N+1):
  for r in range (2,N+1):
    count=0
    while i%r==0:
      i=i/r
      count+=1
    R[r-2]+=count

count=1
for r in range(N-1):
  count=count*(R[r]+1)
print(count%(10**9+7))

Solution (Python):



N = input()
mod = 10**9+7
num = 1
cnt = 0
ans = 1
for i in range(N):
    num = num*(i+1)
for i in range(N-1):
    while(num%(i+2)==0):
        num = num/(i+2)
        cnt += 1
    ans *= (cnt+1)
    ans = ans % mod
    cnt = 0
    
print(ans)

Solution (Python):
def is_prime(n):
    for i in range(2,n):
        if n % i == 0:
            return False
    return True

if __name__ == "__main__":
    N = int(input())
    v = [0]*(N+1)
    for i in range(2, N+1):
        for j in range(2, i+1):
            ii = i
            while ii%j == 0:
                v[j] += 1
                ii = ii / j
    ans = 1
    for i, e in enumerate(v):
        if is_prime(i) == False: continue
        ans *= e+1
    print(ans % (10**9+7))

Solution (Python):
from collections import defaultdict


MOD = 10 ** 9 + 7



def prime_factor_decomposition(n):
    m = defaultdict(int)
    while n > 1:
        find_factor = False

        for i in range(2, int(n ** 1/2) + 1):
            if n % i == 0:
                m[i] += 1
                n //= i
                find_factor = True
                break

        if not find_factor:
            m[n] += 1
            break
    return m


def main():
    N = int(input())
    all_m = defaultdict(int)
    for i in range(1, N + 1):
        m = prime_factor_decomposition(i)

        for k, v in m.items():
            all_m[k] += v

    ans = 1
    for v in all_m.values():
        ans *= (v + 1)
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys

INF = 1000000007

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def ni(): return int(stdin.readline())

n = ni()
x = 1

for i in range(2, n+1):
    x = x*i

c = 0
ans = 1
y = 2
while(x != 1):
    if(x%y == 0):
        x = x//y
        c = c+1
    else:
        ans = ans*(c+1)
        c = 0
        if(y == 2): y = 3
        else: y = y+2

print(ans*(c+1)%INF)

Solution (Python):



n = int(input())
a = [0] * (n+1)

s = 1
for i in range(2, n+1):
    for j in range(2, i):
        if i % j == 0:
            break
    else:
        for k in range(2, n+1):
            while k >= i:
                if k % i == 0:
                    a[i] += 1
                    k /= i
                else:
                    break

for i in range(2, n+1):
    if a[i] != 0:
        a[i] += 1
        s *= a[i]

print(s % (pow(10, 9) + 7))

Solution (Python):
import math

def primes(N):
    ps = []
    for i in range(2,N+1):
        flag = True
        for p in ps:
            if(i % p == 0):
                flag = False
        if(flag):
            ps.append(i)
    return ps

def p_counter(p, number):
    count = 0
    while True :
        if(number % p == 0):
            number = number//p
            count += 1
        else:
            break
    return count


if __name__=="__main__":
    N = int(input())
    ps = primes(1000)
    N = math.factorial(N)
    cs = [p_counter(p, N) for p in ps]
    pattern = 1
    for c in cs:
        pattern *= (c+1)
    ans = pattern % (10**9 + 7)
    print(ans)

Solution (Python):
from math import factorial as fact
from functools import reduce

def is_prime(n):
    if n < 2:
        return False
    else:
        for i in range(2, n):
            if i * i > n:
                break
            elif n % i == 0:
                return False
        return True

def divc(n, d):
    c = 0
    while n % d == 0:
        c = c + 1
        n = n // d
    return c

n = int(input())
pl = [p for p in range(1, 1001) if is_prime(p)]
cl = [divc(fact(n), d) for d in pl]
ans = reduce(lambda x, y: x * y, [c + 1 for c in cl]) % (10 ** 9 + 7)
print(ans)

Solution (Python):
def add_prime_factor(x, list_N):
    for i in range(2, x+1):
        count = 0
        while True:
            if x % i != 0:
                break
            count += 1
            x //= i
        list_N[i-1] += count
        if x == 1:
            break
    return list_N

if __name__ == '__main__':
    N = int(input())
    list_N = [0] * N
    for i in range(2, N+1):
        list_N = add_prime_factor(i, list_N)
    ans = 1
    for x in list_N:
        ans *= (x + 1)
    print(ans % (10**9 + 7))

Solution (Python):

"""
Created on Wed Feb  8 15:39:57 2017

@author: kes31
"""


import numpy as np

N = int(input())

orig = np.arange(1,N+1)
data = np.arange(1,N+1)
cont = np.zeros_like(data)
for m in range(2,N+1):
    while(True):
        ct = 0
        mask = (data%m)==0
        data[mask]=data[mask]//m
        ct = np.sum(mask)
        cont[m-1]+=ct
        if ct == 0:
            break

alcount = 1
for c in cont:
    alcount = alcount*int(c+1)
alcount = np.mod(alcount,1000000007)
print (alcount)

Solution (Python):
N = int(input())
ps = [0] * (N+1)
for i in range(2,N+1):
  x = i
  p = 2
  while x > 1 :
    while x % p == 0:
      ps[p] += 1
      x //= p
    p += 1
ans = 1
for c in ps:
  ans = (ans * (c+1)) % 1000000007
print(ans)

Solution (Python):

import math
def isPrime(n):
    i = 2
    while i*i <= n:
        if n%i == 0:
            return False
        i += 1
    return True

table = []
N = int(input())
for tmp in range(2,N+1):
    if isPrime(tmp):
        table.append(tmp)

table2 = [0 for i in range(len(table))]

factorial = 1
for num in range(2,N+1):
    factorial *= num
    factor = 0
    for i in table:
        while num >= i and num%i == 0:
            table2[factor] += 1
            num /= i
        factor += 1

ans = 1
for tmp2 in table2:
    ans *= tmp2+1





ans = ans % ((10 ** 9) + 7)
print(ans)

Solution (Python):
import math
x=int(raw_input())

prime=[True]*(x+1)
prime[0:2]=[False]*2
for i in range(2,x+1):
    if prime[i]:
        for j in range(i*2,x+1,i):
            prime[j]=False

prime_num=[0]*(x+1)

for i in range(0,x+1):
    if prime[i]:
        j=i
        while True:
            prime_num[i]+=x/j
            j*=i
            if j>x:
                break


print reduce(lambda p,x:p*(x+1),prime_num,1)%(10**9+7)

Solution (Python):

import math
N=int(input())
def prime_list(k):
    lis=[True for i in range(1,k+1)]
    lis[0]=False
    for i in range(2,k+1):
        j=2
        while j*j<=i:
            if i%j==0:
                lis[i-1]=False
                break
            else:
                j+=1
    return lis

def p_fact(k,N,plist):

    lis=[0]*N
    for i in range(0,k):
        n=0
        if plist[i]:
            while k%(i+1)==0:
                n+=1
                k=k/(i+1)
        lis[i]=n
    return lis

out_lis=[0]*N
plist=prime_list(N)
for i in range(1,N+1):
    input_lis=p_fact(i,N,plist)
    out_lis=[out_lis[j]+input_lis[j] for j in range(0,N)]

out=1
for i in range(0,N):
    out=out*(out_lis[i]+1)

print(out%(10**9+7))

Solution (Python):
N = int(input());

P = [0]*N;

D = 1;
if N>=2:
    for i in range(2,N+1):
        for j in range(2,i+1):
            while i%j ==0:
                P[j-1] = P[j-1]+1;
                i = i/j
for i in range(N):
    D = D*(P[i]+1)
print(D%1000000007);

Solution (Python):

import math
N=int(input())
def prime_list(k):
    lis=[True for i in range(1,k+1)]
    lis[0]=False
    for i in range(2,k+1):
        j=2
        while j*j<=i:
            if i%j==0:
                lis[i-1]=False
                break
            else:
                j+=1
    return lis

def p_fact(k,N):
    plist=prime_list(k)
    lis=[0]*N
    for i in range(0,k):
        n=0
        if plist[i]:
            while k%(i+1)==0:
                n+=1
                k=k/(i+1)
        lis[i]=n
    return lis
out_lis=[0]*N
for i in range(1,N+1):
    input_lis=p_fact(i,N)
    out_lis=[out_lis[j]+input_lis[j] for j in range(0,N)]

out=1
for i in range(0,N):
    out=out*(out_lis[i]+1)
print(out%1000000007)

Solution (Python):
prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443,
         449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
n = int(input())
ans = 1
for i in prime:
    if i <= n:
        m = n
        multi = 0
        while m >= i:
            multi += m // i
            m = m // i
        multi += 1
        ans *= multi
print(ans % (10**9 + 7))

Solution (Python):
def isPrime(n):
	i = 2
	while i*i <= n:
		if n % i == 0:
			return False
		i += 1
	return True

N = 1000
Prime = []

for i in range(2,N):
	if isPrime(i):
		Prime.append(i)
		
dic = {}
for i in Prime:
	dic[i] = 0

p = int(input())
for k in range(2, p+1):
	for i in Prime:
		while k % i == 0:
			k /= i
			dic[i] += 1

ans = 1
for i in Prime:
	ans *= (1+dic[i])

print(ans % 1000000007)

Solution (Python):
prime=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997)

n=int(input())
ans=1
for p in prime:
    k=1
    m=0
    while p**k <=n:
        m += n//p**k

        k +=1

    ans *= m+1

print(ans % (10**9+7))

Solution (Python):
from collections import Counter
N = int(raw_input())
d = Counter()

for i in range(1, N+1):
    n = i
    for p in range(2, i+1):
        while n % p == 0:
            n /= p
            d[p] += 1
ans = 1
for p in d:
    ans *= d[p] + 1
    ans %= 10 ** 9 + 7
print ans

Solution (Python):
MOD = int(1e9 + 7)
n = int(input())

es = [0] * 1010


def div(x):
    if x == 1: return
    for i in range(2, x + 1):
        while x % i == 0:
            es[i] += 1
            x //= i


for i in range(1, n + 1):
    div(i)

ans = 1
for i in range(1, n + 1):
    ans *= es[i] + 1

print(ans % MOD)

Solution (Python):


import collections
import functools
import math
import operator


P = 1000000007


def sieve_of_eratosthenes(end):
    assert end > 1
    is_prime = [True for _ in range(end)]
    is_prime[0] = False
    is_prime[1] = False
    primes = []
    for i in range(2, end):
        if is_prime[i]:
            primes.append(i)
            for j in range(2 * i, end, i):
                is_prime[j] = False
    return primes


def factorize_fact(n, primes):
    factors = collections.Counter()
    if n < 2:
        return factors
    for p in primes:
        if p * p > n:
            break
        while n % p == 0:
            factors[p] += 1
            n //= p
    if n > 1:
        factors[n] += 1
    return factors


def sum_ctrs(counters):
    return functools.reduce(operator.add, counters, collections.Counter())


def prod_mod(iterable, mod=P):
    def multi_mod(x, y):
        return (x % mod) * (y % mod) % mod
    return functools.reduce(multi_mod, iterable, 1)


def sum_of_divs_of_fact(n, mod=P):
    primes = sieve_of_eratosthenes(math.ceil(math.sqrt(n)) + 1)
    ctr = sum_ctrs(factorize_fact(x, primes) for x in range(1, n + 1))
    ans = prod_mod(v + 1 for v in ctr.values()) % mod
    return ans


def main():
    print(sum_of_divs_of_fact(int(input())))


if __name__ == '__main__':
    main()

Solution (Python):


n=int(raw_input())
s=[1 for i in range(n+1)]
res=1
for i in range(2,n+1):
 if s[i]:
  for j in range(i*2,n+1,i):
   s[j]=0
  cnt=0
  temp=n
  while temp:
   cnt+=temp/i
   temp/=i
  res=res*(cnt+1)%(10**9+7)
print res

Solution (Python):
import math
 
N = int(input())
mod = 10**9+7
 
def get_primes(n):
    ps = [0, 0] + [i for i in range(2, n+1)]
    for i in range(2, n+1):
        if ps[i] == 0:
            continue
        for j in range(i * i, n+1, i):
            ps[j] = 0
    return [p for p in ps if p]
 
 
prime = get_primes(N)
 
ans = 1
for p in prime:
    tmp = 0
    for i in range(1, int(math.log(N, p))+1):
        tmp += N // (p**i)
 
    ans = (ans * (tmp + 1)) % mod
 
print(ans)

Solution (Python):
from functools import reduce

MOD = 10**9 + 7
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443,
          449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
N = int(input())
arr = []

for p in primes:
    if p <= N:
        pow_p = p
        s = 0
        while pow_p <= N:
            s += N // pow_p
            pow_p *= p
        arr.append(s + 1)

if N == 1:
    print(1)
else:
    print(reduce(lambda a, b: (a * b) % MOD, arr))

Solution (Python):
from functools import reduce
MOD = 10**9 + 7
primes = list(map(int, "2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997".split(" ")))

N = int(input())
arr = []

for p in primes:
    if p <= N:
        pow_p = p
        s = 0
        while pow_p <= N:
            s += N // pow_p
            pow_p *= p
        arr.append(s+1)

if N == 1:
    print(1)
else:
    print(reduce(lambda a, b: (a * b) % MOD, arr))

Solution (Python):
import math

N = int(input())
mod = 10**9+7

def get_primes(n):
    ps = [0, 0] + [i for i in range(2, n+1)]
    for i in range(2, n+1):
        if ps[i] == 0:
            continue
        for j in range(i * i, n+1, i):
            ps[j] = 0
    return [p for p in ps if p]


prime = get_primes(N)

ans = 1
for p in prime:
    tmp = 0
    for i in range(1, int(math.log(N, p))+1):
        tmp += N // (p**i)

    ans = (ans * (tmp + 1)) % mod

print(ans)

Solution (Python):
import math
n = int(input())

MOD = 10**9 + 7
prime = [True] * (n+1)

p = 2
while p*p <= n:
    for i in range(p*2, n+1, p):
        prime[i] = False
    p += 1

allPrimes = []
for p in range(2, n+1):
    if prime[p]:
        allPrimes.append(p)

res = 1

for i in range(len(allPrimes)):
    p = allPrimes[i]
    
    n_exp = 0
    while (p <= n):
        n_exp += n//p
        p *= allPrimes[i]

    res = (res * (n_exp + 1)) % MOD

print(res)

Solution (Python):









from math import floor as gs
N = int(input())


def fun_prime(k):
    counter = 0
    primes = [2, 3]

    for n in range(5, k+1, 2):
        isprime = True
        for i in range(1, len(primes)):
            if primes[i] ** 2 > n:
                break
            if n % primes[i] == 0:
                isprime = False
                break
        if isprime == True:
            primes.append(n)
    return(primes)
primes_N = fun_prime(N)

ans = 1
if N == 1:
    print(int(ans))
else:
    for prime in primes_N:
        e = 0
        power = prime
        while power <= N:
            e += gs(N/power)
            power = power * prime
        ans = ans * (e + 1)
    ans = ans % (10 ** 9 + 7)
    print(int(ans))

Solution (Python):
pr = [True] * 1001
n = int(input())
ans = 1
MOD = 10 ** 9 + 7
 
for i in range(2, n + 1):
    if pr[i]:
        for j in range(i * 2, n + 1, i):
            pr[j] = False
        cnt = 0
        now = n
        while now:
            cnt += now // i
            now //= i
        ans = ans * (cnt + 1) % MOD
 
print(ans)

Solution (Python):
n = int(input())

prime = []
table = [True] * (n + 1)

for i in range(2, n + 1):
    if not table[i]:
        continue
    k = i + i
    while k < n + 1:
        table[k] = False
        k += i

    prime.append(i)

ans = 1
for p in prime:
    k = 0
    for i in range(1, n + 1):
        v = i
        while v % p == 0:
            v //= p
            k += 1
    ans *= k + 1

print(ans % 1000000007)

Solution (Python):
from collections import defaultdict
from functools import reduce

P = 10**9 + 7

N = int(input())

rem = list(range(2, N+1))
dic = defaultdict(int)

while len(rem) > 0:
  n = rem[-1]
  for d in range(2, int(n**0.5) + 1):
    if n % d == 0:
      dic[d] += 1
      rem[-1] //= d
      break
  else:
    dic[n] += 1
    rem.pop()

print(reduce(lambda x, y: x*(y+1)%P, dic.values(), 1))

Solution (Python):

import collections

n = int(input())

sosu = []

for i in range(1, n+1):
    if (2 ** i-1) % i == 1:
        sosu.append(i)


yakusu = collections.Counter()

for i in range(1, n+1):
    for j in sosu:
        if i < j:
            break
        elif i % j == 0:
            while i % j == 0 or i < 1:
                yakusu[j] += 1
                i = i / j




ans = 1
for i in yakusu.values():
    ans *= (i+1)
print(ans % (10**9 + 7))

Solution (Python):
import math
import collections

n = int(input())
nf = math.factorial(n)
sosu = []

for i in range(1, n+1):
    if (2 ** i-1) % i == 1:
        sosu.append(i)


yakusu = collections.Counter()

for i in range(1, n+1):
    for j in sosu:
        if i < j:
            break
        elif i % j == 0:
            while i % j == 0 or i < 1:
                yakusu[j] += 1
                i = i / j




ans = 1
for i in yakusu.values():
    ans *= (i+1)
print(ans % (10**9 + 7))

Solution (Python):
n = int(input())

prime = []
for i in range(2,1001):
	f = True
	for j in range(2,i):
		if i % j == 0:
			f = False
			break
	if f == True:
		prime.append(i)


c,total = 1,1

for p in prime:
	if p > n:
		continue
	for i in range(1,100):
		if p**i <= n:
			c += n // p**i
		else:
			total *= c
			c = 1
			break
		
print(total % (10**9+7))

Solution (Python):
import math

def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff

def divisor_num(n):
    a = 1
    for _ , x in factorization(n):
        a *= x + 1
    return a

n = int(raw_input())
nx = math.factorial(n)
print divisor_num(nx) % (10**9 + 7)

Solution (Python):


import collections

def factorial(n):
    a = 1
    for i in xrange(1, n + 1):
        a *= i
    return a

def prime_decomposition(n):
    i = 2
    counter = []
    while i < n:
        while n % i == 0:
            n /= i
            counter.append(i)
        i += 1

    if n > 1:
        counter.append(n)
    return counter

n = input()
a = factorial(n)

res = [v for v in collections.Counter(prime_decomposition(a)).values()]

divisor = 1
for i in res:
    divisor *= (1 + i)

print divisor % (10 ** 9 + 7)

Solution (Python):
n = int(input())

def primes(n):
	p_list = [2]
	for i in range(2, n+1):
		for p in p_list:
			if i%p == 0:
				break
		else:
			p_list.append(i)

	return p_list

p_list = primes(n)
x = [1]*len(p_list)

for j in range(1, 1+n):
	temp = j*1
	index = 0

	while temp > 1:
		if temp%p_list[index] == 0:
			temp = temp/p_list[index]
			x[index] += 1
		else:
			index += 1

count = 1
for n in x:
	count = (count*n)%(10**9+7)

print(int(count))

Solution (Python):

def add_facs(facsA, facsB):
	for fac in facsB:
		if fac in facsA:
			facsA[fac] += facsB[fac]
		else:
			facsA[fac] = facsB[fac]
	return facsA
	
def factorize(n_init):
	facs = {}
	n = n_init
	i = 2
	while (n > 1) and (i < n):
		if n%i == 0:
			add_facs(facs, factorize(i))
			n = n//i
		else:
			i += 1
			
	if (n == i):
		facs[n] = 1
		
	return facs
	

N = int(input())

perN = 1
for i in range(2,N+1):
	perN *= i
	
res_facs = factorize(perN)
num = 1
for fac in res_facs:
	num = num * (res_facs[fac] + 1)

print(num%(10**9+7))

Solution (Python):
N = int(input())


nums = list(range(2,N+1))
primes = []
while nums:
    p = nums.pop(0)
    nums = [x for x in nums if x % p]
    primes.append(p)

    

factors_list = [[0] * len(primes), [0] * len(primes)]
for n in range(2, N+1):
    for i, p in enumerate(primes):
        div, mod = divmod(n, p)
        if mod == 0:
            fct = factors_list[div][:]
            fct[i] += 1
            factors_list.append(fct)
            break
            

factors_of_factorial = [sum(x) for x in zip(*factors_list)]
result = 1
for prod in factors_of_factorial:
    result *= prod+1
    result %= 1000000007
print(result)

Solution (Python):
import sys
import functools

mod = 1e9 + 7
n = int(input())
if n == 1:
    print(1)
    sys.exit()

fact = [1] * (n+1)

for i in range(2, n+1):
    for j in range(2, 32):
        if i == 0:
            break
        while True:
            if i % j == 0:
                i /= j
                fact[j] += 1
            else:
                break
    if i != 0:
        fact[int(i)] += 1

print(int(functools.reduce(lambda x, y: (x * y) % mod, fact[2:])))