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):
n=int(input())

mod=10**9+7

def prime_fact(x):
    fact=[]
    for i in range(2, int(x**(0.5))+1):
        while x%i==0:
            fact.append(i)
            x//=i
    if x!=1:
        fact.append(x)
    if not fact:
        fact=[x]
    return fact

def eratosthenes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

era=eratosthenes(n)
d={}
for key in era:
    d[key]=0

for i in range(2,n+1):
    prime_list=prime_fact(i)
    for prime in prime_list:
        d[prime]+=1

ans=1
for key in d:
    ans*=(d[key]+1)%mod

print(ans%mod)

Solution (Python):
from collections import defaultdict

def prime_factorize(N): 
    exponent = 0
    while N%2 == 0:
        exponent += 1
        N //= 2
    if exponent: factorization = [[2,exponent]]
    else: factorization = []
    i=1
    while i*i <=N:
        i += 2
        if N%i: continue
        exponent = 0
        while N%i == 0:
            exponent += 1
            N //= i
        factorization.append([i,exponent])
    if N!= 1: factorization.append([N,1])
    assert N != 0, "zero"
    return factorization

N = int(input())

if N <= 2:
    print(N)
    exit()
else:
    num = defaultdict(int)
    for i in range(2,N+1):
        for n,m in prime_factorize(i):
            num[n] += m


ans = 1
mod = int(1e9+7)
for i in num.values():
    ans = ((i+1)*ans)%mod

print(ans)

Solution (Python):
from collections import defaultdict

def factorization(n):
  res = []
  for i in range(2, int(n**0.5//1) + 1):
    if n%i == 0:
      cnt = 0
      while n%i==0:
        n = n//i
        cnt += 1
      res.append([i,cnt])

  if n != 1:
    res.append([n,1])

  return res

N = int(input())
factors = defaultdict(int)
factors[1] = 1
for i in range(2, N+1):
  f = factorization(i)
  for d,cnt in f:
    factors[d] += cnt

mod = 10**9+7
res = 1
for i in range(2, N+1):
  res *= (factors[i]+1)
  res %= mod

print(res)

Solution (Python):


import sys










from collections import Counter              



















def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    import math
    class Eratos:
        def __init__(self, num):
            '''
            O(nlglgn) で num までの素数判定テーブルを作る
            >>> e = Eratos(10)
            >>> e.table
            [False, False, True, True, False, True, False, True, False, False, False]
            '''
            assert(num >= 1)
            self.table_max = num
            
            self.table = [False if i == 0 or i == 1 else True for i in range(num+1)]
            for i in range(2, int(math.sqrt(num)) + 1):
                if self.table[i]:
                    for j in range(i ** 2, num + 1, i):    
                        self.table[j] = False
        
        def is_prime(self, num):
            '''
            O(1) で素数判定を行う
            >>> e = Eratos(100)
            >>> [i for i in range(1, 101) if e.is_prime(i)]
            [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]
            '''
            assert(num >= 1)
            if num > self.table_max:
                raise ValueError('Eratos.is_prime(): exceed table_max({}). got {}'.format(self.table_max, num))
            return self.table[num]
        
        def prime_factorize(self, num):
            '''
            O(√n) で素因数分解を行う
            >>> e = Eratos(10000)
            >>> e.prime_factorize(6552)
            {2: 3, 3: 2, 7: 1, 13: 1}
            '''
            assert(num >= 1)
            if int(math.sqrt(num)) > self.table_max:
                raise ValueError('Eratos.prime_factorize(): exceed prime table size. got {}'.format(num))
            
            factorized_dict = dict()
            candidate_prime_numbers = [i for i in range(2, int(math.sqrt(num)) + 1) if self.is_prime(i)]
            
            
            for p in candidate_prime_numbers:
                if num == 1:    
                    break
                if num % p == 0:
                    cnt = 0
                    while num % p == 0:
                        num //= p
                        cnt += 1
                    factorized_dict[p] = cnt
            if num != 1:
                factorized_dict[num] = 1
            return factorized_dict
        
        def enum_divisor(self, num):
            '''
            O(√n) で約数列挙を行う
            >>> e = Eratos(10000)
            >>> e.enum_divisor(4)
            [1, 2, 4]
            >>> e.enum_divisor(19)
            [1, 19]
            >>> e.enum_divisor(100)
            [1, 2, 4, 5, 10, 20, 25, 50, 100]
            '''
            divisor_small = []
            divisor_large = []
            for i in range(1, int(math.sqrt(num)) + 1):
                if num % i == 0:
                    divisor_small.append(i)
                    if i != num // i:
                        divisor_large.append(num // i)
            divisor_large.reverse()
            return divisor_small + divisor_large
    
    n = ii()
    eratos = Eratos(n)
    if n == 1:
        print(1)
    else:
        c = Counter()
        for i in range(2, n+1):
            d = eratos.prime_factorize(i)
            c += Counter(d)
        ans = 1
        for k, v in c.items():
            ans = (ans * (v + 1)) % mod
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import math

N = int(input())
N = math.factorial(N) 

i = 2 
num = 1
ans = 1

while N != 1: 
    if N % i == 0:
        N = N // i
        num += 1
    else:
        ans *= num
        num = 1
        i += 1
ans *= num
ans %= (10 ** 9) + 7

print(ans)

Solution (Python):
prime_list = [2]
N = int(input())
A = [0] * N

for i in range(3,10**3+1):
  flag = True
  for j in range(2,int(i**0.5)+1):
    if i % j == 0:
      flag = False
      break
  if flag:
    prime_list.append(i)

for i in range(1,N+1):
  
  tmpN = i
  for j in prime_list:
    while tmpN % j == 0:
      A[j-1] += 1
      tmpN //= j
ans = 1
p = 10**9 + 7
for i in range(1,N):
  ans *= (A[i] + 1)
  ans %= p
print(ans)

Solution (Python):
from math import factorial

N = int(input())
N = factorial(N)

i = 2
num = 1
ans = 1

while N != 1:
    if N % i == 0:
        N //= i
        num += 1
    else:
        ans *= num
        num = 1
        i += 1
ans *= num
ans %= (10**9) + 7

print(ans)

Solution (Python):
from collections import Counter
N = int(input())
mod = 10 ** 9 + 7

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

primes = []
for i in range(1, N + 1):
    primes += prime_factorize(i)

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

Solution (Python):
import math
n = int(input())
mod = 10**9+7

def is_prime(n):
	if n == 1:
		return False
	
	for k in range(2, int(math.sqrt(n)) + 1):
		if n%k == 0:
			return False
	return True

p = []
for i in range(1,n+1):
	if is_prime(i):
		p.append(i)
ans = 1
for i in p:
	s = 0
	x = i
	while x <= n:
		s += n//x
		x *= i
	ans *= (s+1)
	ans %= mod
print (ans)

Solution (Python):
from collections import defaultdict
MOD=10**9+7
N=int(input())

def factorize(M):
  fact=defaultdict(int)
  for i in range(2,int(M**0.5)+1):
    if M==1:
      break
    while(M%i==0):
      M//=i
      fact[i]+=1
  
  if M!=1:
    fact[M]=1
  return fact

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


answer=1
for v in pdic.values():
  answer*=(v+1)
  answer%=MOD
  
print(answer)

Solution (Python):
from collections import defaultdict
factors = defaultdict(int)
N = int(input())
for i in range(2,N+1):
    target = i
    d = 2
    while d**2 <=target:
        if target % d == 0:
            factors[d] += 1
            target //= d
        else:
            d += 1

    if target != 1:
        factors[target] += 1
ans = 1
for v in factors.values():
    ans *= (v+1)
mod = 10**9 +7
print(ans%mod)

Solution (Python):

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

class Mint:
    
    MOD = 10**9+7
    
    def __init__(self, x=0):
        self.x = (x%self.MOD + self.MOD) % self.MOD
    
    def __iadd__(self, other):
        self.x += other.x
        if self.x >= self.MOD:
            self.x -= self.MOD
        return self
    
    def __isub__(self, other):
        self.x += self.MOD - other.x
        if (self.x >= self.MOD):
            self.x -= self.MOD
        return self
    
    def __imul__(self, other):
        self.x *= other.x
        self.x %= self.MOD;
        return self;
    
    def __add__(self, other):
        ans = Mint(self.x)
        ans += other
        return ans
        
    def __sub__(self, other):
        ans = Mint(self.x)
        ans -= other
        return ans
    
    def __mul__(self, other):
        ans = Mint(self.x)
        ans *= other
        return ans
    
    def __pow__(self, n):
        if n == 0:
            return Mint(1)
        a = self.__pow__(n >> 1)
        a *= a
        if n&1:
            a *= self
        return a
    
    def inv(self):
        return self**(self.MOD-2)
    
    def __ifloordiv__(self, other):
        self *= other.inv()
        return self
    
    def __floordiv__(self, other):
        ans = Mint(self.x)
        ans //= other
        return ans
        

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

def Main(N):
    if N == 1:
        return 1
    ans = []
    for i in range(2, N+1):
        ans += prime_factorize(i)
    counter = Counter(ans)
    val = [v+1 for v in counter.values()]
    a = Mint(1)
    for v in val:
        a *= Mint(v)
    return a.x
          
                    
print(Main(N))

Solution (Python):
from collections import defaultdict
from functools import reduce
from math import sqrt
def factorint(n):
    d = {}
    for i in range(2, int(sqrt(n))+1):
        c = 0
        q, r = divmod(n, i)
        while not r:
            c += 1
            n = q
            q, r = divmod(n, i)
        if c:
            d[i] = c
    if n != 1:
        d[n] = 1
    return d

n = int(input())
mod = 10**9 + 7
A = defaultdict(lambda:1)
for i in range(1, n+1):
    for k, v in factorint(i).items():
        A[k] += v

print(reduce(lambda x, y: x*y % mod, A.values()) if A else 1)

Solution (Python):
from collections import defaultdict
from functools import reduce
from math import sqrt
def factorint(n):
    d = dict()
    for i in range(2, int(sqrt(n))+1):
        q, r = divmod(n, i)
        if r == 0:
            c = 0
            while r == 0:
                n = q
                c += 1
                q, r = divmod(n, i)
            d[i] = c
    if n != 1:
        d[n] = 1
    return d

n = int(input())
mod = 10**9 + 7
A = defaultdict(lambda:1)
for i in range(1, n+1):
    for k, v in factorint(i).items():
        A[k] += v

print(reduce(lambda x, y: x*y % mod, A.values()) if A else 1)

Solution (Python):
def main():
    from math import factorial
    n = int(input())
    mod = 10 ** 9 + 7
    nf = factorial(n)
    l = f(nf)
    ans = 1
    for x in l:
        ans *= (x + 1)
    ans %= mod
    print(ans)


def f(n):
    l = []
    for i in range(2, n + 1):
        if n == 1:
            break
        count = 0
        while n % i == 0:
            n = n // i
            count += 1
        if count > 0:
            l.append(count)
    return l


if __name__ == '__main__':
    main()

Solution (Python):


import numpy as np







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


num = [0] * (n + 1)


for i in range(2, n + 1):
    temp = i
    
    while (temp % 2 == 0):
        if (num[2] == 0):
            num[2] = 1
        num[2] += 1
        
        temp //= 2

    f = 3
    
    while (f * f <= temp):
        if (temp % f == 0):
            if (num[f] == 0):
                num[f] = 1
            num[f] += 1
            
            temp //= f
        else:
            f += 2
    
    if (temp != 1):
        if (num[temp] == 0):
            num[temp] += 1
        num[temp] += 1
        

numA = np.array(num)
numAA = np.argwhere(numA != 0)
numAAA = numAA.tolist()


ans = 1
for i in numAAA:
    tar = i[0]
    ans *= num[tar]


ans %= lim

print(ans)

Solution (Python):
n = int(input())
arr = [1]*(n+1)
mod = 10**9+7
def factorization(n):
    global arr
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] += cnt%mod

    if temp!=1:
        arr[temp] += 1
        arr[temp] %= mod

    if arr==[]:
        arr[n] += 1
        arr[n] %= mod


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



anslist = [0]*(n+1)
anslist[1] = arr[1]%mod
for i in range(2,n+1):
    anslist[i] = anslist[i-1]*arr[i]
print(anslist[n]%mod)

Solution (Python):
import collections as col

def prime(n):
    ans = []
    num = n
    for i in range(2,int(n**0.5)+1):
        if i%2==0 and i!=2: continue
        while num%i == 0: num //= i ; ans.append(i)
    if num != 1: ans.append(num)
    return ans

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

primes = []
for i in range(2,n+1): primes += prime(i)

cnt = col.Counter(primes)
ans = 1
for key,val in cnt.items(): ans *= (val + 1) ; ans %= mod
print(ans)

Solution (Python):
import collections as col

def prime(n):
    ans = []
    num = n
    for i in range(2,n+1):
        if i%2==0 and i!=2: continue
        while num%i == 0: num //= i ; ans.append(i)
    return ans

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

primes = []
for i in range(2,n+1): primes += prime(i)

cnt = col.Counter(primes)
ans = 1
for key,val in cnt.items(): ans *= (val + 1) ; ans %= mod
print(ans)

Solution (Python):
import collections as col

def prime(n):
    ans = []
    num = n
    for i in range(2,n+1):
        if i%2==0 and i!=2: continue
        while num%i == 0: num //= i ; ans.append(i)
    return ans

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

primes = []
for i in range(2,n+1): primes += prime(i)

cnt = col.Counter(primes)
ans = 1
for key,val in cnt.items(): ans *= (val + 1)
print(ans%mod)

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):


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int((n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n=int(input())
p=10**9+7
fli=[1]*(n+1)
for i in range(2,n+1):
  f=factorization(i)
  for j in range(len(f)):
    fli[f[j][0]]+=f[j][1]
ans=1
for i in range(n+1):
  ans=ans*fli[i]%p
print(ans)

Solution (Python):
import collections
N = int(input())
num = []
mod = 10**9+7
for i in range(2,N+1):
    for j in range(2,i+1):
        
        while i%j==0:
            i //= j
            num.append(j)

A = collections.Counter(num)

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

Solution (Python):
from collections import Counter
n=int(input())
l=[]
for i in range(2,n+1):
    k=2
    t=i
    while k*k<=t:
        if t%k==0:
            l.append(k)
            t=t//k
        else:k+=1
    if n>0:l.append(t)

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

Solution (Python):
n = int(input())
def factorize(n):
    b = 2
    fct = [(1,1)]
    while b * b <= n:
        cnt =0
        while n % b == 0:
            n //= b
            cnt +=1
        if cnt >=1:
            fct.append((b,cnt))
        b = b + 1
    if n > 1:
        fct.append((n,1))
    return fct

primes = [0]*(n+1)
for i in range(1,n+1):
    for num,cnt in factorize(i):
        if num==1:continue
        primes[num] +=cnt
ans = 1
mod = 10**9+7
for cnt in primes:
    ans = ans*(cnt+1)%mod
print(ans)

Solution (Python):
import math
from collections import defaultdict

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

dp = [0] * (N + 1)

def prime_factorize(n):
    divisors = []
    
    temp = n
    for i in range(2, int(math.sqrt(n)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                
                temp //= i
            divisors.append([i, cnt])
    if temp != 1:
        divisors.append([temp, 1])
    if divisors == []:
        divisors.append([n, 1])

    return divisors

for i in range(1, N + 1):
    for j in prime_factorize(i):
        if j[0] > 1:
            dp[j[0]] += j[1]

for i in dp:
    if i > 0:
        ans = (ans * (i + 1)) % mod
print(ans % mod)

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

def prime_factorize(n):
    prime_fact = []
    while n%2 == 0:
        prime_fact.append(2)
        n//=2
    f = 3
    while f * f <= n:
        if n % f == 0:
            prime_fact.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        prime_fact.append(n)
    return prime_fact

n = int(input())
a = 1
ans = 0
for i in range(1,n+1):
    a *= i
c = prime_factorize(a)
d = collections.Counter(c)
ans = 1
for value in d.values():
    ans *= (value+1)
    ans %= MOD
print(ans)

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

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

dic = {i:0 for i in range(n+1)}
for i in range(2, n+1):
    l = prime_decomposition(i)
    for x in l:
        dic[x] += 1
ans = 1
for k,v in dic.items():
    if v!=0:
        ans *= (v+1)
        ans %= mod
print(ans%mod)

Solution (Python):
from collections import defaultdict
N = int(input())
MOD = 10**9 + 7


def f(v):
    a = 2
    dic = defaultdict(int)
    while v != 1:
        if v % a == 0:
            dic[a] += 1
            v //= a
        else:
            a += 1
    return dic


if N == 1:
    print(1)
    exit()

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


ans = 1
for value in dic.values():
    ans *= value + 1
    ans %= MOD
print(ans)

Solution (Python):
import functools
def primes(n):

    prime_list = list(range(n+1))
    prime_list[1] = 0
    for i in range(2, int(n)+1):
        if prime_list[i] != 0:
            for j in range(2*i, n+1, i):
                prime_list[j] = 0

    return [i for i in prime_list if i != 0]

def solve(n):

    prime_list = primes(n)
    powers = []
    for p in prime_list:
        tmp = 0
        a = p
        while a <= n:
            tmp += n // a
            a *= p
        powers.append(tmp)

    ans = functools.reduce(
        lambda acc, x: (acc*(x+1)) % (10**9+7), powers, 1)

    return ans

if __name__ == "__main__":
    n = int(input())
    print(solve(n))

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

nn = math.factorial(n)

if n ==1:
    print(1)
    
elif n ==2:
    print(2)
else:
    sosu =[2]  
   
    for i in range(3,n+1,2):
        judge = 0
        for j in range(2,i):
            if i % j == 0:
                judge = 1
        if judge ==0:
            sosu.append(i)
    
    slist =[0]*len(sosu)
    for k in range(0,len(sosu)):
        m = nn
        count = 0
        while m % sosu[k] ==0:
            m = m //sosu[k]
            count +=1
        slist[k] = count
    
    res = 1
    for l in range(0,len(slist)):
        res =res*(slist[l]+1) % 1000000007

    print(res)

Solution (Python):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

MOD=10**9+7

n=int(input())
li=[0]*2000

for i in range(1,n+1):
    c=factorization(i)
    
    for j in range(len(c)):
        li[c[j][0]]+=c[j][1]

ans=1

for i in range(2,n+1):
    ans=ans*(li[i]+1)
    ans=ans%MOD

print(ans)

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr

n=int(input())
dat = [0] * 2000 

res = 1
for i in range(1, n + 1):
    d = factorization(i)
    
    for j in range(len(d)):
        dat[d[j][0]] += d[j][1]



for i in range(2, n + 1):
    res *= (dat[i] + 1)
    res %= mod

print(res)

Solution (Python):
n = int(input())
num = [0]*(n+1)
ans = 1
for i in range(2,n+1):
    j=2
    while j<n+1 and i>1:
        if i%j==0:
            i=i//j
            num[j]+=1
        else:
            j+=1
for i in num:
    ans=ans*(i+1)%1000000007
print(ans)

Solution (Python):
import math

N = int(input())

dic = {}
for n in range(2, N + 1):
    p = 2
    while 1 < n and p <= math.sqrt(n):
        if n % p == 0:
            while n % p == 0:
                n //= p
                dic[p] = dic.get(p, 0) + 1
        p += 1

    if n > 1:
        if n not in dic:
            dic[n] = 1
        else:
            dic[n] += 1

ret = 1
for v in dic.values():
    ret *= v + 1

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

Solution (Python):
import sys
readline = sys.stdin.readline
from collections import Counter
MOD = 10 ** 9 + 7

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

def main():
    N = int(readline())
    factors = []
    for i in range(1, N+1):
        factors += factorize(i)
    c = Counter(factors)
    ans = 1
    for key, val in c.items():
        if key == 1:
            continue
        ans *= (val + 1)
        ans %= MOD
    
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def resolve():
    N = int(input())
    d = {}
    for i in range(2, N+1):
        for j in prime_factors(i):
            d[j] = d[j] + 1 if j in d else 1
    res = 1
    for v in d.values():
        res *= (v+1)
    print(res%(10**9+7))

def prime_factors(n):
    i = 2
    factors = []
    while i**2 <= n:
        if n % i != 0:
            i += 1
        else:
            factors.append(i)
            n = n // i
    if n > 1:
        factors.append(n)
    return factors

if '__main__' == __name__:
    resolve()

Solution (Python):
N = int(input())
if N == 1:
    print(1)
    exit()

primes = list(range(2, N + 1))
prime_index = 0
n = primes[prime_index]
while n**2 <= N:
    primes = list(filter(lambda x: x == n or x % n != 0, primes))
    prime_index += 1
    n = primes[prime_index]

exponents = [0 for _ in range(len(primes))]
for n in range(2, N + 1):
    for prime_index, prime in enumerate(primes):
        exponent = 0
        tmp = n
        while tmp % prime == 0:
            tmp //= prime
            exponent += 1
        exponents[prime_index] += exponent

const = 10**9 + 7
answer = 1
for e in exponents:
    answer = answer * (e + 1)
    answer %= const
print(answer)

Solution (Python):

def Eratosthene(n):
    prime = [1]*(n+1)
    prime[0] = 0
    prime[1] = 0

    for i in range(2, int(n**0.5)+1, 1):
        if prime[i]==0:
            continue
        for j in range(i+1, n+1, 1):
            if prime[j]==0:
                continue
            if j%i==0:
                prime[j] = 0
    return prime

prime = Eratosthene(10**3)
P = []
for i in range(10**3+1):
    if prime[i]==1:
        P.append(i)

N = int(input())

ANS = 1
for p in P:
    a = p
    ans = 0
    while 1:
        if N/p>0:
            ans = ans + int(N/p)
        else:
            break
        p = p*a
    ANS = ANS * (ans+1)
print(ANS%(10**9+7))

Solution (Python):
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    
    if temp != 1:
        arr.append([temp, 1])
    if not arr:
        arr.append([n, 1])
    
    return arr


def solve():
    N = int(rl())
    MOD = 10 ** 9 + 7
    
    counter = defaultdict(int)
    for i in range(2, N + 1):
        facts = factorization(i)
        for j, cnt in facts:
            counter[j] += cnt
    
    ans = 1
    for val in counter.values():
        ans = ans * (val + 1) % MOD
    print(ans)


if __name__ == '__main__':
    solve()

Solution (Python):
import math

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

def eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

if n==1:
    print(1)
    exit()

era = eratosthenes(n)

dict = {}
for i in range(n):
    num = i+1
    while num!=1:
        for j in era:
            while num%j==0:
                num/=j
                if j in dict:
                    dict[j]+=1
                else:
                    dict[j]=1

ans = 1
for i in dict:
    ans = ans*(dict[i]+1)%mod

print(ans)

Solution (Python):
from collections import defaultdict as dd
N = int(input())

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
res = 1
MOD = 10**9+7
dic = dd(int)
for i in range(1,N+1):
    f = factorize(i)
    for val in f:
        dic[val] += 1
for val in dic.values():
    res = res*(val+1)%MOD
print(res)

Solution (Python):
from math import factorial
from collections import defaultdict

n = int(input())
cnt = defaultdict(int)
n = factorial(n)
i = 2
while n >= i:
    if n % i == 0:
        n //= i
        cnt[i] += 1
    else:
        i += 1    
ans = 1

for k, v in cnt.items():
    ans *= v + 1

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

Solution (Python):
import sys
input = sys.stdin.readline
def prime_factorize(n, ex_table):
    for i in range(2, int(n**0.5)+1):
        if n % i != 0:continue
        while n % i == 0:
            ex_table[i] += 1
            n = n//i
    if n != 1:ex_table[n] += 1
def main():
    N = int(input())
    ex_table = {i:0 for i in range(2, N+1)}
    for i in range(1, N+1):
        prime_factorize(i, ex_table)
    ans = 1
    MOD = 10 ** 9 + 7
    for k in ex_table:
        ans *= (ex_table[k] + 1)
        ans %= MOD
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    l=[0]*(N+1)
    for i in range(1,N+1):
        a=2
        while i>1:
            if i%a==0:
                l[a]+=1
                i//=a
            else:
                a+=1
    
    ans=1
    for x in l:
        ans*=x+1
        ans%=MOD
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
def prime_factorize(n):
  
  a = []
  while n % 2 == 0:
    a.append(2)
    n = n // 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n = n // f
    else:
      f += 2
  if n != 1:
    a.append(n)
  return a

def abc052_c():
  n = int(input())
  if n == 1:
    print(1)
    return

  
  primes = []
  for i in range(2, n+1):
    primes += prime_factorize(i)

  
  
  div = 10**9 + 7
  ans = 1
  from collections import Counter
  for kv in Counter(primes).items():
    ans = ans * (kv[1] + 1) % div
  print(ans)

abc052_c()

Solution (Python):
n = int(input())
dp = list(0 for _ in range(n+1))

for i in range(2,n+1):
  
  while i%2==0:
    dp[2] += 1
    i //= 2
  f = 3
  while f*f<=i:
    if i%f==0:
      dp[f] +=1
      i //= f
    else:
      f += 2
  if i!=1:
    dp[i] += 1

s = 1
for i in dp:
  if i!=0:
    s *= i+1
print(s%(10**9+7))

Solution (Python):
def is_prime(q):
    if q < 2 or q&1 == 0: return False
    return pow(5, q-1, q)*pow(7, q-1, q) == 1
  
def main():
  mod = 10**9+7
  n = int(input())
  ans = 1
  if n == 1:
    print(1)
    exit()
  
  b = [2]
  for i in range(2,min(n+1,998)):
    if i == 5 or i == 7:
      b.append(i)
    if i == 561:
      continue
    if is_prime(i):
      b.append(i)
      
  for i in b:
    p = i
    cnt = 1
    chk = 1
    for j in range(10):
      chk += n//p
      if p > n:
        ans *= chk
        ans %= mod
        chk = 1
        break
      p *= i
      
  print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
def divisor(n):
    if n % 2 == 0:
        return 2
    elif n % 3 == 0:
        return 3
    maxitr = intSqrt(n)
    i = 1
    while True:
        i += 4
        if i > maxitr:
            return n
        elif n % i == 0:
            return i
        i += 2
        if i > maxitr:
            return n
        elif n % i == 0:
            return i


def factorization(n, simple=True):
    result = []
    while n > 1:
        div = divisor(n)
        result.append(div)
        n //= div
    return result


def intSqrt(n):
    x = 1
    while True:
        x2 = (x + n // x) // 2
        if abs(x - x2) <= 1:
            break
        x = x2
    return x2


def ABC052C(n):
    factor = []
    for i in range(2, n+1):
        factor.extend(factorization(i))
    
    d = {}
    for c in factor:
        if c in d.keys():
            d[c] += 1
        else:
            d.setdefault(c, 1)
    ans = 1
    for key, value in d.items():
        ans = (ans * (value + 1)) % 1000000007
    print(ans)

ABC052C(int(input()))