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):
M = 1000000000 + 7

N = int(input())

primes = set()
factorCounter = [0] * (N + 1)

for i in range(2, N + 1):
    n = i
    isPrime = True
    for prime in primes:
        while n > 0 and n % prime == 0:
            n //= prime
            factorCounter[prime] += 1
            isPrime = False

    if isPrime:
        factorCounter[i] += 1
        primes.add(i)
        

ans = 1
for prime in primes:
    ans *= factorCounter[prime] + 1
    ans %= M

print(ans)

Solution (Python):

def prime_t(t):
    i=2
    while i**2<=t:
        if t%i==0:
            return 0
        i+=1
    return 1
p=[]

for i in range(2,1008):
    if prime_t(i):
        p.append(i)
d={i:0 for i in p}
mod=10**9+7
n=int(input())
tmp=1
ans=1
R=[i for i in range(168)]
for i in range(1,n+1):
    tmp*=i
    for j in R:
        while tmp%p[j]==0:
            d[p[j]]+=1
            tmp//=p[j]
        if tmp<p[j]:
            break
for i in d:
    ans*=(d[i]+1)
    ans%=mod
print(ans)

Solution (Python):


n=int(input())

from math import sqrt
from random import randint

def isprime(num): 
	root=int(sqrt(n))
	for i in range(2,root+1):
		if num%i==0:
			return(False)
	return(True)

def isprime_(num, n=1): 
	q = num
	if q == 2:
		return(True)
	if q ==1 or q&1 == 0:
		return(False)
	d = (q-1)>>1
	while d&1 == 0:
		d >>= 1
	for i in range(n):
		a = randint(1,q-1)
		t = d
		y = pow(a,t,q)
		while t != q-1 and y != 1 and y != q-1: 
			y = pow(y,2,q)
			t <<= 1
		if y != q-1 and t&1 == 0:
			return(False)
	return(True)

def dividers(num, sort=True):
	root=int(sqrt(n))
	l=[]
	m=[]
	for i in range(1,root+1):
		if num%i==0:
			l.append(i)
			if i<root:
				m.append(int(num/i))
	if sort:
		l.extend(sorted(m))
		return(l)
	else:
		l.extend(m)
		return(l)

def decomposit(num):
	root=int(sqrt(n))
	l=[]
	i=2
	while i<root+1:
		if num%i==0:
			j=0
			while(num%i==0):
				j+=1
				num=num/i
			l.append([i,j])
			root=int(sqrt(n))
		i+=1
	if num!=1:
		l.append([int(num),1])
	return(l)

l={}
for i in range(n+1):
	if isprime_(i):
		l[i]=0

for i in range(1,n+1):
	for j in decomposit(i):
		l[j[0]]+=j[1]

d=1
for i in l.values():
	d*=i+1

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

Solution (Python):
def pd(n,p):
    if n%p==0:
        return pd(n/p,p)+1
    else:
        return 0


Plist=[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(raw_input())
if N==1:
    print 1
else:
    A=[1 for i in Plist]
    for n in range(1,N+1):
        for p in range(len(Plist)):
            A[p]+=pd(n,Plist[p])
    B=1000000007
    ans=1
    for a in A:
        ans*=a
        ans%=B
    print ans

Solution (Python):
import math

def primefactor(n):
    r = []
    a, b = 0, 2
    while b * b <= n:
        if n % b == 0:
            n //= b
            r += [b]
        else:
            b += 1 + a
            a = 1
    if n > 1 : r += [n]
    return r

N = int(input())
M = math.factorial(N)
D = 10**9+7

c = {}
for i in primefactor(M):
    if i in c:
        c[i] += 1
    else:
        c[i] = 2
ans = 1
for k, v in c.items():
    ans = (ans * v) % D
print(ans)

Solution (Python):
import itertools,math,bisect,pprint,sys
l = 10**9+7
n = input()
table = []
table2 = []
def prime_decomposition(n):
  i = 2
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
prime_decomposition(math.factorial(n))
pn = 0
while pn < len(table):
    t = table.count(table[pn])
    table2.append(t+1)
    pn += t
res = 1
for i in table2:
    res *= i
print res%l

Solution (Python):
import numpy as np
from collections import Counter

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


N = int(input())

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):
from collections import defaultdict
def primefactor(x):
    fac=defaultdict(int)
    for i in xrange(2,int(x**0.5)+1):
        while x%i==0:
            fac[i]+=1
            x=x/i
    if x!=1:
        fac[x]+=1
    return fac

n=int(raw_input())
mod=10**9+7
ans=1
cnt=defaultdict(int)
for i in xrange(1,n+1):
    tmp=primefactor(i)
    for j,k in tmp.items():
        cnt[j]+=k
for i,j in cnt.items():
    ans=ans*(j+1)%mod
print(ans%mod)

Solution (Python):
import collections

MOD = (10 ** 9 + 7)

n = int(input())
p = [True for i in range(n+1)]
p[0] = False
p[1] = False
pf = collections.defaultdict(int)
for i in range(2, n+1):
    if not p[i]:
        continue
    j = i * i
    while j <= n:
        p[j] = False
        j += i
    cnt = 1
    v = i
    while v <= n:
        cnt += n//v
        v *= i
    pf[i] = cnt
total = 1
for v in pf.values():
    total = (total * v) % MOD

print(total)

Solution (Python):



from collections import *

MOD = 1000000007
N = int(input())
nums = list(range(1,N+1))
d = defaultdict(int)
for i in range(1, N):
    ni = nums[i]
    if ni == 1:
        continue
    for j in range(i, N):
        while nums[j] % ni == 0:
            nums[j] //= ni
            d[ni] += 1
ans = 1
for v in d.values():
    ans = (ans * (v + 1)) % MOD
print(ans)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

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 main():
    n = II()
    d = collections.defaultdict(int)
    for i in range(1,n+1):
        for k,v in factorization(i):
            d[k] += v
    r = 1
    for c in d.values():
        r *= c+1
        r %= mod
    return r


print(main())

Solution (Python):
from collections import Counter
def factorize(n):
	from math import sqrt
	r = int(sqrt(n))
	a = []
	while not n % 2:
		a.append(2)
		n //= 2
	for m in range(3,r+1,2):
		while not n % m:
			a.append(m)
			n //= m
	if n != 1:
		a.append(n)
	return Counter(a)
mod = 10**9 + 7
N = int(input())
c = Counter()
for i in range(2,N+1):
	c += factorize(i)

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

Solution (Python):
n = input()
dis = {}
for x in xrange(2, n+1):
    i = 2
    while i*i <= x:
        while x % i == 0:
            dis[i] = dis.get(i, 0) + 1
            x /= i
        i += 1
    if x>1:
        dis[x] = dis.get(x, 0) + 1
ans = 1
for k in dis:
    ans = (ans * (dis[k]+1)) % (10**9+7)
print ans