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):
mod = 10**9+7
def hmf(n, k, k1):
    x = n//k
    if not x:
        return 0
    return x + hmf(n, k*k1, k1)

primes = [i for i in range(10**3+1)]
primes[1] = 0 

for p in primes:
    if p > int(10**(3/2)): break
    if p == 0: continue
    for non_prime in range(2 * p, 10**3+1, p): 
        primes[non_prime] = 0
    prime = [prime for prime in primes if prime != 0]

N = int(input())
ans = 1
for p in prime:
    c = hmf(N, p, p)
    if not c:
        break
    ans = ans*(1+hmf(N, p, p))%mod
print(ans)

Solution (Python):
n = int(input())
if n < 3:
    print(n)
    exit()

primes = [2]

import math
for i in range(3, n+1):
    k = int(math.sqrt(i))
    flag = True
    for p in primes:
        if p > k:
            break
        if  i%p == 0:
            flag = False
            break
    if flag:
        primes.append(i)

ans = 1
for p in primes:
    k = n
    cnt = 0
    while k:
        k = k//p
        cnt += k
    
    ans *= cnt + 1
ans = ans % (10**9 + 7)
print(ans)

Solution (Python):
N=int(input().strip())
flis=[0]*1001
inf=(10**9)+7
def fact(n):
    global flis
    for i in range(2,n+1):
        while n%i==0:
            n=n//i
            flis[i]+=1


def solve(n):
    ans=1
    for i in range(1,n+1):
        fact(i)
    for i in range(1,n+1):
        ans*=(flis[i]+1)
    return ans

print(solve(N)%inf)

Solution (Python):
import sys
import collections
import math
from collections import Counter
from collections import deque

N = int(input())

d = 10**9 + 7


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


cnt = Counter()

for i in range(2, N + 1):
    prime_list = prime_decomposition(i)
    tmpCnt = Counter(prime_list)
    cnt.update(tmpCnt)



ans = 1
for i in cnt.items():
    ans *= (i[1] + 1)

print(ans % d)

sys.exit(0)

Solution (Python):
n = int(input())
from collections import defaultdict
d = defaultdict(int)
mod = 1000000007
for i in range(2,n+1):
  for j in range(2,i+1):
    while i%j ==0 and i != 0:
      d[j] += 1
      i//=j
ans = 1
for i in d.values():
  ans *= (i+1)
  ans %= mod
print(ans)

Solution (Python):
N=int(input())
list1=[1 for i in range(N+1)]

for i in range(1,N+1):
    X=i
    for j in range(2,N+1):
        while X%j==0:
            if X==0:
                pass
            elif X%j==0:
                list1[j]+=1
                X=X/j
ans=1   
for k in range(len(list1)):
    ans*=list1[k]
    
print(ans%1000000007)

Solution (Python):
import math

LL = [0 for i in range(1001)]

N = int(input())


for i in range(1,N + 1):
	L = []
	if i == 1:
		pass
	elif i == 2:
		LL[2] += 1
	else:
		n = int(math.sqrt(N) // 1)
		x = 2
		for j in range(n + 2):
			while True:
				if i % x == 0:
					L.append(x)
					i = int(i // x)
				else:
					break
			x += 1
		if i != 1:
			L.append(i)
	for j in L:
		LL[j] += 1


ans = 1
for i in LL:
	if i == 0:
		pass
	else:
		ans = ans * (i + 1)
		ans = ans % 1000000007

print(ans)

Solution (Python):
def prime(n):
    p_list=[2]
    for i in range(3,n+1):
        flag=True
        for p in p_list:
            if i%p==0:
                flag=False
                break
        if flag:
            p_list.append(i)
    return p_list
    
p_list=prime(1000)
N=int(raw_input())
p_count = [1 for i in range(len(p_list))]
for i in range(len(p_list)):
    j=1
    p=p_list[i]
    count=0
    while p**j <=N:
        count+=int(N/(p**j))
        j+=1
    p_count[i]+=count

ans=1
for c in p_count:
    ans= (ans*c)%(10**9+7)
print ans

Solution (Python):
S=int(input());
s=[];
x=[];
X=[];
so=[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];
ans=1;
for h in range(S):
    Y=h+1;
    for i in so:
        j=0;
        while Y%i==0:
            Y=Y/i;
            s=s+[i];
            j+=1;
for i in so:
    x=x+[s.count(i)];
X=[X+1 for X in x];
for i in X:
    ans=ans*i;
print(ans%1000000007);

Solution (Python):
import math
def prime(n): 
    import math
    if n == 1:
        return []
    else:
        num_list = [i + 1 for i in range(2,n,2)]
        list_prime = [2]
        limit = math.sqrt(n)
        if n == 2:
            return list_prime
        else:
            while True:
                p = num_list[0]
                if p >= limit:
                    return list_prime + num_list
                list_prime.append(p)
                num_list = [num for num in num_list if num % p != 0]

def primeFactorization(n):
    if n == 1:
        return {}
    list_prime = prime(int(x))
    i = 0
    dict_pF = {}
    dict_primeFactorization = {}
    for pri in list_prime:
        dict_pF[pri] = 0
    while True:
        if n == 1:
            for key, value in dict_pF.items():
                if value != 0:
                    dict_primeFactorization[key] = value
            return dict_primeFactorization
        elif i >= len(list_prime):
            dict_pF[n] = 1
            for key, value in dict_pF.items():
                if value != 0:
                    dict_primeFactorization[key] = value
            return dict_primeFactorization
        p = list_prime[i]
        if n % p == 0:
            n //= p
            dict_pF[p] += 1
            continue
        else:
            i += 1


x = int(input())
ans_dict = primeFactorization(math.factorial(x))
ans = 1
for value in ans_dict.values():
    ans *= value+1
print(ans%(10**9 + 7))

Solution (Python):
import math

MOD = 10 ** 9 + 7

def factorizec(n):
    fct = []
    b = 2
    e = 0
    while b * b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b, e))
        b += 1
        e = 0
    if n > 1:
        fct.append((n, 1))
    return fct

n = int(input())
fct = factorizec(math.factorial(n))
ans = 1
for i in fct:
    ans *= (i[1] + 1) % MOD
print(ans % MOD)

Solution (Python):


import math
from collections import defaultdict

def primes(n): 
    prime = [True] * (n + 1)
    prime[0] = False
    prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            prime[j] = False
    return [i for i in range(n + 1) if prime[i]]
        
def factorize(n):
    result = defaultdict(int)
    for p in primes(n):
        while n % p == 0:
            n = n // p
            result[p] += 1
    return result

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

fact = defaultdict(int)
for i in range(2, N+1):
    for key, value in factorize(i).items():
        fact[key] += value

ans = 1
for i in fact.values():
    ans *= i+1
    ans %= mod
print(ans)

Solution (Python):
from collections import Counter
N = int(input())
c = Counter()
for i in range(2, N + 1):
    for j in range(2, int(i ** .5) + 1):
        while i % j == 0:
            c[j] += 1
            i //= j
    if i > 1:
        c[i] += 1
mod = 10 ** 9 + 7
ans = 1
for v in c.values():
    ans = ans * (v + 1) % mod
print(ans)

Solution (Python):
import math
n = int(input())
lis = [0 for i in range(n)]
for i in range(2,n+1):
  cou = 2
  while i >= cou:
    if i % cou == 0:
      lis[cou-1] += 1
      i //= cou
    else:
      cou += 1
cou = 1
for i in range(len(lis)):
  cou *= (lis[i]+1)
  cou %= (10 ** 9+7)
print(cou)

Solution (Python):


from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

N = input()
div = [1] * 1100

for i in range(N):
    num = i + 1
    for den in range(2, 1000):
        while num % den == 0:
            num /= den
            div[den] += 1

ans = 1
MOD = 10 ** 9 + 7
for num in div:
    ans *= num
    ans %= MOD
print ans

Solution (Python):
import math


def primes(x):
    if x < 2: return []
    primes = [i for i in range(x)]
    primes[1] = 0
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0
    return [p for p in primes if p != 0]


N = int(input())
ans = 1
for p in primes(N+1):
    k = 0
    for n in range(1,N+1):
        while n%p==0:
            n /= p
            k += 1
    ans *= k+1
    ans %= 1000000007
print(ans)

Solution (Python):

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

d = {}
for i in range(2,n+1):
    for j in range(2,i+1):
        while i%j==0:
            if j not in d:
                d[j] = 1
            d[j] += 1
            i = i//j
ret = 1
for v in d.values():
    ret = (ret*v)%MOD
print(ret)

Solution (Python):
from collections import defaultdict
import sys
class Prime:
    def __init__(self,number):
        self.jud=[True]*(number+5)
        self.pri=[]
        self.jud[0]=False
        self.jud[1]=False
        for i in range(number):
            if self.jud[i]:
                self.pri.append(i)
                for j in range(2,(number)//i+1):
                    self.jud[i*j]=False
    
    def judge(self,x):
        return self.jud[x]
    
    def decom(self,x):
        s=x
        a =defaultdict(int)
        if s==1:
            return a
        while s>1:
            for p in self.pri:
                if s%p==0:
                    a[p]+=1
                    s=s//p
                    break
        return a
            
N=int(input())
mod=10**9+7
if N==1:
    print(1)
    sys.exit()
A=Prime(10**3+1)
dd=defaultdict(int)
for i in range(2,N+1):
    for p,j in A.decom(i).items():
        dd[p]+=j
ans=1
for j in dd.values():
    ans*=j+1
    ans%=mod
print(ans)

Solution (Python):
n = int(input())
a = {}

for i in range(1,n+1):
    b = 2
    while i > 1:
        if i % b == 0:
            if b in a:
                a[b] += 1
            else:
                a[b] = 1
            i = i//b
        else:
            b += 1
ans = 1
for i in a:
    ans *= a[i]+1
print(ans%1000000007)

Solution (Python):
MOD = 10**9+7
n = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in range(2, n+1):
  j = 2
  while j*j<=i:
    while i%j==0:
      i //= j
      d[j] += 1
    j += 1
  if i>1:
    d[i] += 1
ans = 1
for ele in d.values():
  ans = ans*(ele+1)%MOD
print(ans)

Solution (Python):
n=int(input())+1
u=[0 for i in range(n)]
for i in range(2,n):
  for j in range(2,n):
    while i%j==0:
      i=i//j
      u[j]+=1
a=1
for i in range(n):
  a*=u[i]+1
print(a%(10**9+7))

Solution (Python):
prime = [2]
flag = 1
for i in range(3,1000):
    for j in prime:
        if i % j == 0:
            flag = 0
            break
    if flag == 1:
        prime.append(i)
    flag = 1
N = int(input())
ans = 1
mod = 10**9+7
kosu = [0]*1000
for i in prime:
    for j in range(1,N+1):
        hoge = j
        while hoge % i == 0:
            hoge /= i
            kosu[i] += 1
for i in kosu:
    ans *= (i+1)
    ans  = ans % mod
print(ans)

Solution (Python):
import math
from collections import Counter
def getinputdata():

    
    array_result = []
    
    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()
            
            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])

mysum = math.factorial(n)

i = 2

if mysum==1:
    
    arr=[]

else:

    arr = []
    while i < mysum:

        if mysum % i == 0:

            arr.append(i)

            mysum = mysum // i

        else:

            i+=1

    else:

        arr.append(i)


list01=Counter(arr)

cnt=1
for k in list01:

    cnt *=list01[k]+1

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

Solution (Python):
N = int(input())
ans = 1
mod = pow(10,9)+7

INSU = {}


import math
for j in range(2,N+1):
    I=j
    s=0
    R=int(I)
    L=[]
    while s==0:
        for i in range(2,R+1):
            if I%i==0:
                I=I/i
                if I==1:
                    s=1
                L.append(i)
                break
    if len(L)==1:
        
        INSU[R] = 1
    else:
        
        for l in L: INSU[l] += 1
    ans = 1
    for insu in INSU:
        ans = (ans*(INSU[insu]+1))%mod
        
print(ans)

Solution (Python):
from collections import defaultdict

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

d = defaultdict(lambda:0)
for n in range(2,N+1):
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1

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

Solution (Python):
from collections import Counter
from math import sqrt
def fact(n):
    l = int(sqrt(n))
    a = []
    while not n%2:
        a.append(2)
        n //= 2
    for i in range(3,l+1,2):
        while not n%i:
            a.append(i)
            n //= i
    if n != 1:
        a.append(n)
    return Counter(a)


n = int(input())
c = Counter()
mod = 10**9 + 7
ans = 1
for j in range(1,n+1):
    c += fact(j)
for i in list(c.values()):
	ans = ans * (i+1)%mod
print(ans)

Solution (Python):
n=int(input())
import math
import collections
mod=10**9+7
fac=math.factorial(n)
ans=[0]*(n+1)
ans[0]=ans[1]=1
i=2
while i*i<=n:
    j=2
    while i*j<=n and ans[i]==0:
        ans[i*j]=1
        j+=1
    i+=1
v=[]
for i in range(n+1):
    if ans[i]==0:
        v.append(i)
v.sort()
num=[]
for k in v:
    while fac%k==0:
        fac//=k
        num.append(k)
data=collections.Counter(num)
cnt=1
for i,j in data.items():
    cnt*=j+1
print(cnt%mod)

Solution (Python):

n=int(input())
use=[0 for i in range(n+1)]
for i in range(1,n+1):
    for j in range(2,n+1):
        while i%j==0 and i!=1:
            i=i//j
            use[j]+=1
ans=1
for i in range(len(use)):
    if use[i]!=0:
        ans*=use[i]+1
print(ans%1000000007)

Solution (Python):

import math
from collections import Counter
N = int(input())


def f(n):
    temp = n
    c = Counter()
    for i in range(2, n):
        if temp == 1:
            break
        while temp%i == 0:
            temp = temp//i
            c.update([i])
    else:
        c.update([temp])
    return c

c = Counter()
for i in range(2, N+1):
    c.update(f(i))

ans = 1
for _, x in c.items():
    ans = ans*(x+1) % 1000000007

print(ans)

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

prime = [True] * 1001
prime[0] = prime[1] = False
primes = []
for i in range(2, 1001):
  if prime[i]:
    primes.append(i)
    for j in range(i*i, 1001, i):
      prime[j] = False

soinsuu = {}
for i in range(1, N+1):
  x = i
  for p in primes:
    while x % p == 0:
      soinsuu[p] = soinsuu.get(p, 0) + 1
      x //= p

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

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

fs = [0] * N
for i in range(2, N + 1):
    d = 2
    while i > 1:
        if i % d == 0:
            fs[d - 1] += 1
            i //= d
        else:
            d += 1

MOD = 10 ** 9 + 7
ans = 1
for f in fs:
    ans *= (f + 1)
    ans %= MOD

print(ans)

Solution (Python):

from functools import reduce
from operator import mul
def inpl(): return list(map(int, input().split()))
 
def primes(max_number):
    if max_number <= 2:
        raise StopIteration
    yield 2
    is_prime = [1] * max_number
    square_root_of_max = max_number ** 0.5
    for number in range(3, max_number, 2):
        if is_prime[number] is 0:
            continue
        yield number
        if number <= square_root_of_max:
            for multiple in range(number * 2, max_number, number):
                is_prime[multiple] = 0

N = int(input())
P = tuple(primes(10**3))
D = {k:1 for k in P}

for p in P:
    tmp = p
    while True:
        if tmp > N:
            break
        else:
            D[p] += N//tmp
        tmp *= p

print(reduce(mul, D.values())%(10**9+7))

Solution (Python):
from collections import defaultdict

MOD = 1000000007


def prime_generator(limit):
    yield 2
    n, h = 3, {}
    while n <= limit:
        m = n
        if n in h:
            b = h[n]
            m += 2 * b
            while m in h:
                m += 2 * b
            h[m] = b
            del h[n]
        else:
            m += 2 * n
            while m in h:
                m += 2 * n
            h[m] = n
            yield n
        n += 2


def solve(n):
    ps = list(prime_generator(n))
    factors = defaultdict(int)
    for i in range(1, n):
        k = i + 1
        for p in ps:
            while k % p == 0:
                k //= p
                factors[p] += 1
            if k == 1:
                break

    ans = 1
    for c in factors.values():
        ans *= c + 1
        ans %= MOD
    return ans


print(solve(int(input())))

Solution (Python):
from collections import defaultdict

MOD = 1000000007


def prime_generator(limit):
    yield 2
    n, h = 3, {}
    while n <= limit:
        m = n
        if n in h:
            b = h[n]
            m += 2 * b
            while m in h:
                m += 2 * b
            h[m] = b
            del h[n]
        else:
            m += 2 * n
            while m in h:
                m += 2 * n
            h[m] = n
            yield n
        n += 2


def solve(n):
    ps = list(prime_generator(n))
    prev = defaultdict(int)
    for i in range(1, n):
        f = prev.copy()
        k = i + 1
        for p in ps:
            while k % p == 0:
                k //= p
                f[p] += 1
            if k == 1:
                break
        prev = f

    ans = 1
    for c in prev.values():
        ans *= c + 1
        ans %= MOD
    return ans


print(solve(int(input())))

Solution (Python):
n = int(raw_input())
mod = 10**9 + 7
prime = [True for i in range(n + 1)]

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

		curr = i
		exponent = 0

		while curr <= n:
			exponent += n / curr
			curr *= i

		res *= (exponent + 1)
		res %= mod

print res

Solution (Python):
import numpy
mod=10**9+7
def primesfrom2to(n):
    """, Returns a array of primes, 2 <= p < n """
    if n==1:return numpy.array([])
    if n==2:return numpy.array([])
    if n==3:return numpy.array([2])
    if n==4:return numpy.array([2,3])
    if n==5:return numpy.array([2,3])
    sieve = numpy.ones(n//3 + (n%6==2), dtype=numpy.bool)
    for i in range(1,int(n**0.5)//3+1):
        if sieve[i]:
            k=3*i+1|1
            sieve[       k*k//3     ::2*k] = False
            sieve[k*(k-2*(i&1)+4)//3::2*k] = False
    return numpy.r_[2,3,((3*numpy.nonzero(sieve)[0][1:]+1)|1)]
n=int(input())
table=[]
for i in primesfrom2to(n+1):
    i=int(i)
    cnt=0
    originalp=i
    p=originalp
    while True:
        tmp=n//p
        if tmp==0:
            break
        else:
            p*=originalp
            cnt+=tmp
    table.append(cnt)
ans=1

for i in table:
    ans=(ans*(i+1))%mod
print(ans)

Solution (Python):
from collections import defaultdict


def eratos(n):
    if n <= 1:
        return []
    used = [False] * n
    used[0] = used[1] = True
    primes = []
    for i in range(n):
        if used[i] is False:
            primes.append(i)
            for j in range(i * 2, n, i):
                used[j] = True
    return primes


n = int(input())
primes = eratos(n + 1)
primes_dict = defaultdict(lambda: zip(primes, [1] * len(primes)))
X = n
d = 2
defactors = defaultdict(int)

for i in range(2, n + 1):
    if primes_dict[i] == 1:
        defactors[i] += 1
        continue

    for prime in primes:
        if i == 1:
            continue
        while i % prime == 0:
            defactors[prime] += 1
            i //= prime

ans = 1
mod = 10 ** 9 + 7
for key, value in defactors.items():
    ans = (ans * (value + 1)) % mod 
print(ans)

Solution (Python):
primes = [2]

MOD = 10**9 + 7
def isPrime(n):
    if n % 2 == 0 or n < 2:
        return False
    for i in range(3,int(n/2)):
        if n % i == 0:
            return False
    return True

for i in range(3,1000,2):
    if isPrime(i):
        primes.append(i)


N = int(input())
factors = [[0 for j in range(N)] for i in range(len(primes))]

for i in range(N):
    j = i+1
    tmp = j
    a = 0
    while primes[a] <= tmp:
        if tmp % primes[a] == 0:
            factors[a][i] += 1
            tmp /= primes[a]
        else:
            a += 1
l = [sum(t) for t in factors]
ans = 1
for i in l:
    ans *= i+1
print(ans % MOD)

Solution (Python):
import collections
MOD = 10**9+7
def list_prime(n):
    if n < 2:
        return []
    elif n == 2:
        return [2]
    is_prime = [True for i in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n):
        for j in range(i*i, n+1, i):
            is_prime[j] = False
    prime = []
    for i in range(n+1):
        if is_prime[i]:
            prime.append(i)
    return prime

def cnt_factor(n, p):
    cnt = 0
    pi = p
    while pi <= n:
        cnt += n //pi
        pi *= p
    return cnt

n = int(input())
p_list = list_prime(n)
cnt = 1
for p in p_list:
    cnt = cnt * (cnt_factor(n, p)+1) % MOD
print(cnt)

Solution (Python):

import math
import sys
import itertools
import numpy as np
import functools
mo = 1000000007
r = range

n = int(input())

primes = set()
for i in r(2, 1000):
    for p in primes:
        if i % p == 0:
            break
    else:
        primes.add(i)

d = {}
for i in r(2, n+1):
    x = i
    while x != 1:
        for p in primes:
            if x % p != 0:
                continue;
            x //= p
            if p not in d:
                d[p] = 0
            d[p] += 1
            break

ret = 1
for i in d.values():
    ret *= (i+1)
    ret %= mo

print(ret)

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

prime_string = "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 "
prime_list = map(int,prime_string[:-1].split())

power_list = [0 for l in range(len(prime_list))]

for n in range(N):
    for i in range(len(prime_list)):
        for j in range(9):
            if (n+1)%(prime_list[i]**(j+1))==0:
                power_list[i]+=1
result = 1
for power in power_list:
    result=(result*(power+1))%(10**9+7)

print result

Solution (Python):
mod = 10**9 + 7

def factrize(n):
    res = [0]*1001
    i = 2
    while i*i <= n:
        while n%i == 0:
             n /= i
             res[i] += 1
	i += 1
    if n > 1: res[n] += 1
    return res

N = int(raw_input())

ans = 1
cnt = [0]*1001
for i in xrange(1, N + 1):
    tmp = factrize(i)
    for j in xrange(2, 1001):
        cnt[j] += tmp[j]

for i in xrange(2, N + 1):
    ans = ans * (cnt[i] + 1) % mod 
print ans

Solution (Python):


l_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]

from collections import Counter

num_N = int(input())

l_all = []

for num in range(2, num_N + 1):
    for prime in l_prime:
        if prime > num:
            break

        while num % prime == 0:
            l_all.append(prime)
            num /= prime

prime_counter = Counter(l_all)

ans = 1

for count in prime_counter.values():
    ans *= (count + 1)

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

Solution (Python):
import numpy as np
N = int(input())
denom = 10**9+7

prime_counter = {}

def factorize(x):
    for i in range(2, int(N**0.5)+1):
        while (x%i == 0):
            if i not in prime_counter:
                prime_counter[i] = 1
            else:
                prime_counter[i] += 1
            x = x//i
    if x != 1:
        if x not in prime_counter:
            prime_counter[x] = 1
        else:
            prime_counter[x] += 1

for i in range(2,N+1):
    factorize(i)
order_list = list(prime_counter.values())
order_list = [i+1 for i in order_list]
res = 1
for i in range(len(order_list)):
    res = (res*order_list[i])%denom

print(res)

Solution (Python):
def decomp(n):
    i = 2
    res = {}
    while i * i <= n:
        while n % i == 0:
            n //= i
            res[i] = res.get(i, 0) + 1
        i += 1
    if n > 1:
        res[n] = 1
    return res


N = int(input())
d = {}
for i in range(1, N + 1):
    res = decomp(i)
    for k, v in res.items():
        if k != 1:
            d[k] = d.get(k, 0) + v

ans = 1
MOD = int(1e9 + 7)
for e in d.values():
    ans *= (e + 1)
    ans %= MOD
print(ans)

Solution (Python):
import math
target = int(input())
answer = dict()
for factorial in range(2,target + 1):
    while factorial > 1:
        for inner in range(2,math.ceil(math.sqrt(factorial))+1):
            if factorial % inner == 0:
                factorial //= inner
                answer[inner] = answer.get(inner,0) + 1
                break
        else:
            answer[factorial] = answer.get(factorial,0) + 1
            factorial = 1
            
sum_answer = 1
for ans in answer.values():
    sum_answer = (sum_answer * (ans + 1)) % (10**9 + 7)

print(sum_answer)

Solution (Python):
from collections import defaultdict

mod = 10**9+7;

def prime_factorize(n):
    primes = {}
    for i in range(2, int(n**0.5+1)):
        if n%i == 0:
            count = 0
            while n%i == 0:
                n //= i
                count += 1
            primes[i] = count
    if n > 1:
        primes[n] = 1

    return primes

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

    factors = defaultdict(int)

    for i in range(1, n+1):
        for k,v in  prime_factorize(i).items():
            factors[k] += v

    ans = 1
    for v in factors.values():
        ans *= v+1
        ans %= mod
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
primes = [2,3,5,7,11,13,17,19,23,29,31]

memo1 = {}
def factorization(n):
    result = []
    for prime in primes:
        while n % prime == 0:
            n = n / prime
            result.append(prime)
    if n != 1:
        result.append(n)
    return result

def num_of_factors(l):
    if l == []:
        return 1
    if len(l) == 1:
        return 2
    p2num = {}
    for prime in l:
        if prime not in p2num:
            p2num[prime] = 2
        else:
            p2num[prime] += 1
    return reduce(lambda x,y: x * y,p2num.values())

def factors_of_factorials(n):
    l = []
    for i in range(1,n+1):
        l += factorization(i)
    return num_of_factors(l) % (10**9 + 7)


n = int(raw_input())
print factors_of_factorials(n)

Solution (Python):
import math
n=math.factorial(int(input()))
i=2
res=1
MOD=1000000007
while i*i<=n:
	cnt=1
	while n%i==0:
		cnt+=1
		n//=i
	res*=cnt
	i+=1
if n!=1:res*=2
print(res%MOD)

Solution (Python):
pr = [True] * 1001
n = int(input())
ans = 1

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 *= (cnt + 1)

print(ans % 1000000007)

Solution (Python):
def factor(n, d):
    if n == 1:
        return d
    else:
        l = [i+1 for i in range(n) if i != 0]
        l.append(n)
        for x in l:
            if n % x == 0:
                if x in d:
                    d[x] += 1
                else:
                    d[x] = 1
                return factor(n/x, d)

n = int(raw_input())
d = {}
for i in range(n):
    d = factor(i+1, d)

ans = 1
for i in d.values():
    ans *= i+1
print ans % 1000000007

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

a = [0] * (n + 1)

for i in range(2, n + 1):
    x = i
    for j in range(2, i + 1):
        if x < j:
            break
        c = 0
        while x % j == 0:
            x //= j
            c += 1
        if c > 0:
            a[j] += c
    if x > 1:
        a[x] += 1
    
ans = 1
rem = 10 ** 9 + 7
for k in range(2, n + 1):
    if a[k] > 0:
        ans = (ans * (a[k] + 1)) % rem

print(ans)

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

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]
dic = {p:0 for p in primes}

for i in range(N):
    for j in primes:
        tmp = i + 1
        while(tmp % j == 0):
            tmp = tmp // j
            dic[j] += 1

res = 1
for v in dic.values():
    res = res * (v + 1)
    res = res % 1000000007

print(res)

Solution (Python):
from math import factorial

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(int(i))
        i += 1
    if n > 1:
        table.append(int(n))
    return table

def __main__():
    n = int(input())
    if n == 1:
        print(1)
        return
    i = 2
    prime_factors_count = [0] * 1001
    while i <= n:
        prime_factors = prime_decomposition(i)
        for j in range(prime_factors[-1] + 1):
            c = prime_factors.count(j)
            prime_factors_count[j] += c
        i += 1
    c = 1
    for i in range(1001):
        if prime_factors_count[i] != 0:
            c *= prime_factors_count[i] + 1
    print(c % (10**9 + 7))

__main__()