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):
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
from math import *
input = sys.stdin.readline

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def factorization(n):
    
    dic = defaultdict(int)
    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
            dic[i] = cnt
            
    if temp!=1:
        dic[temp] = 1
    if not dic:
        dic[n] = 1

    return dic

def main():
    mod = 10**9 +7
    n = int(input())
    facn = factorial(n)

    pf = defaultdict(int)
    for i in range(1, n+1):
        pfp = factorization(i)
        for j in pfp:
            pf[j] += pfp[j]

    ans = 1
    for i in pf:
        if i == 1:
            continue
        ans *= pf[i] + 1 
        ans %= mod
        
    print(ans)
    return

if __name__ == '__main__':
    main()

Solution (Python):
import math
N=math.factorial(int(input()))
i=2
ans=1
M=10**9+7
while i*i<=N:
    cnt=1
    while N%i==0:
        cnt+=1
        N//=i
    ans*=cnt
    i+=1
if N!=1:ans*=2
print(int(ans%M))

Solution (Python):
from collections import Counter

N = int(input())
count = Counter()
for i in range(2, N+1):
    while i != 1:
        for j in range(2, N+1):
            if i % j == 0:
                i //= j
                count[j] += 1
                break
ans = 1
for x in count.values():
    ans *= (x+1)
    ans %= 10**9+7
print(ans)

Solution (Python):
n = int(input())
for i in range(n-1):
    n *= i+1
y = 1
while n % 2 == 0:
    y += 1
    n //= 2
f = 3
x = 1
while n > 1:
    if n % f == 0:
        x += 1
        n //= f
    else:
        f += 2
        y *= x
        x = 1
else: y *= x
print(y%1000000007)

Solution (Python):
from collections import defaultdict
mod=10**9+7
n=int(input())
sosu_list=[2]
for i in range(3,1002, 2):
    flag=0
    for j in range(2,int(i**.5)+1):
        if i%j==0:
            flag+=1
            break
    if flag==0:
        sosu_list.append(i)
shukei=defaultdict(int)
for i in range(1,n+1):
    soinsu=defaultdict(int)
    for sosu in sosu_list:
        t=i
        while t>0:
            if t%sosu==0:
                soinsu[sosu]+=1
                t//=sosu
            else:
                break
    for a,b in soinsu.items():
        shukei[a]+=b
ans=1
for a in shukei.values():
    ans*=(a+1)
    ans%=mod
print(ans)

Solution (Python):
N = int(input())
NM = 1000
fs = [list() for _ in range(NM+1)]

from collections import Counter
C = Counter()
for i in range(2, N+1):
  if len(fs[i]) == 0:
    for j in range(i, N+1, i):
      d = j
      while j % i == 0:
        fs[j].append(i)
        j //= i
        C[i] += 1

M = 10**9 + 7
ans = 1
for v in C.values():
  ans = (ans * (v+1)) % M
print(ans)

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

mod = 10 ** 9 + 7

count = [0] * (N+1)
def prime_fac(n,c):
    while n % 2 == 0:
        n //= 2
        c[2] += 1
    i = 3
    while n != 1:
        if n % i == 0:
            c[i] += 1
            n //= i
        else:
            i += 2
    return 0
        
for i in range(1,N+1):
    prime_fac(i,count)

ans = 1
for i in count[1:]:
    if i >= 1:
       ans *= (i+1) % mod
       ans %= mod

print(ans)

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

p = [0]*(N+1)

def pf(n):
    x = 2
    done = False
    while done == False:
        if n == 1:
            done = True
        if n % x == 0:
            n = n // x
            p[x] += 1
        else:
            x += 1
    
for i in range(1,N+1):
    pf(i)

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

Solution (Python):
from collections import Counter


def prime_factorize(n):
    p = 2
    fct = []
    
    

    
    
    
    
    
    while n >= p ** 2:
        while n % p == 0:
            n //= p
            fct.append(p)
        p += 1
    if n > 1:
        fct.append(n)
    return fct


N = int(input())
MOD = 1000000007
numbers = []
for i in range(1, N+1):
    numbers += prime_factorize(i)

count_numbers = Counter(numbers)
ans = 1
for n in count_numbers.values():
    ans *= ((n+1) % MOD)

print(ans % MOD)

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

"""約数の個数"""


def factrize(n):
    b = 2
    fct = []
    for i in range(n+1):
        while b*b <= i:
            while i % b == 0:
                i //= b
                fct.append(b)
            b = b+1
        if i > 1:
            fct.append(i)
        b = 2
    
    divisor = dict()
    for i in fct:
        if not i in divisor:
            divisor[i] = 1
        else:
            divisor[i] += 1
    ans = 1
    for i in divisor.values():
        ans *= (i+1)
    return ans

print(factrize(n)%mod)

Solution (Python):
from collections import deque, defaultdict
from functools import reduce
from operator import mul

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


prime_nums = set([2]) if N > 1 else set()
prime_nums = prime_nums.union(set(range(3, N+1, 2)))
queue = deque([i for i in prime_nums if i*i <= N+1])
while queue:
    num = queue.popleft()
    prime_nums.difference_update({i for i in range(num*2, N+1, num)})
prime_nums = sorted(list(prime_nums))


factors = defaultdict(int)
for i in range(2, N+1):
    for j in prime_nums:
        while True:
            if i % j == 0:
                factors[j] += 1
                i //= j
            else:
                break

if N == 1:
    ans = 1
else:
    ans = reduce(mul, [(v+1) % MOD for v in factors.values()])
print(ans % MOD)

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
from _collections import defaultdict
from functools import lru_cache

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True

def fact(n):
    arr = defaultdict(int)
    temp = n
    for i in range(2,Math.roundUp(int(n ** 0.5),1) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt+=1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == []:
        arr[n] = 1
    return arr
MOD = int(1e09) + 7

def main():
    N = cin.int()
    S = defaultdict(int)
    for i  in range(1,N + 1):
        T = fact(i)
        for k,v in T.items():
            S[k] += v
    ans = 1
    for v in S.values():
        ans *= (v+1)
        ans %= MOD
    print(ans)
    return

if __name__ == "__main__":
    main()

Solution (Python):
import sys
from collections import Counter, defaultdict


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
  

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

if N == 1:
  print(1)
  sys.exit()
  
d = defaultdict(int)

for n in range(2, N+1):
  prime_factor = prime_factorize(n)
  for key, value in Counter(prime_factor).items():
    d[key] += value
    
ret = 1
for i in d.values():
  ret *= i + 1
  ret %= MOD
  
print(ret)

Solution (Python):
from collections import Counter
def prime_factorization(n):
    factor = []
    if n == 1:
        factor.append(1)
    for i in range(2,int(n**0.5)+1):
        while n%i == 0:
            n //= i
            factor.append(i)
    if n != 1:
        factor.append(n)
    return factor

n = int(input())
mod = 10**9+7
ans = 1
c = Counter()

for i in range(2,n+1):
    c.update(Counter(prime_factorization(i)))

for key in c:
    ans *= c[key] + 1
    ans %= mod

print(ans)

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

L = [0] * (N)

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

for i in range(1,N + 1):
  P = prime_factorize(i)
  for j in range(len(P)):
    p = int(P[j])
    L[p - 1] += 1
    
total = 1
    
for i in L:
  if i != 0:
    total *= (i + 1)
    
div = 10 ** 9 + 7
  
print(total % div)

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

L = [0] * (N)

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

for i in range(1,N + 1):
  P = prime_factorize(i)
  for j in range(len(P)):
    p = int(P[j])
    L[p - 1] += 1
    
total = 1
    
for i in L:
  if i != 0:
    total *= (i + 1)
    
div = 10 ** 9 + 7
  
print(total % div)

Solution (Python):
n=int(input())
l=[]
mod=10**9+7
d=dict()
for i in range(1,n):
  cnt=0
  k=i+1
  for j in range(1,k):
    if k<j+1:
      break
    while k%(j+1)==0:
      k//=j+1
      cnt+=1
    if j+1 not in d:
      d[j+1]=cnt
    else:
      d[j+1]+=cnt
    cnt=0
d=list(d.items())
if len(d)==0:
  print(1)
else:
  ans=1
  for i in range(len(d)):
    ans*=(d[i][1]+1)%mod
  print(ans%mod)

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



def primes(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]]
ans = 1
mod = 10**9+7
prime = primes(N)
for i in prime:
    isum = 0
    for n in range(2,N+1):
        while n%i == 0:
            isum += 1
            n //= i
    ans = (ans*(isum+1))%mod
print(ans)

Solution (Python):
MOD = 1000000007
N = int(input())
d = dict()

for i in range(2, N+1):
    tmp = i
    div = 2
    while tmp > 1:
        if tmp % div == 0:
            if div not in d:
                d[div] = 1
            else:
                d[div] = d[div] + 1
            tmp = tmp // div
        else:
            div += 1
ans = 1
for div in d:
    ans = ans * (d[div] + 1) % MOD

print(ans)

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

def f(num):
    i = 2
    d = dict()
    while i ** 2 <= num:
        if num % i == 0:
            num //= i
            d[i] = d.get(i, 0) + 1
        else:
            i += 1
    d[num] = 1
    return d

n = int(input())

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

ans = 1
for i in f(math.factorial(n)).values():
    ans *= i+1

print(ans%mod)

Solution (Python):
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor


"""
need to consider the case that ticket is not enough to lower everything
"""

N = gi()
cnt = [0] * (N + 1)

cnt[1] = 1

for i in range(2, N + 1):
    t = i
    for d in range(2, int(sqrt(i)) + 1):
        while (t % d == 0):
            cnt[d] += 1
            t = t // d

    if (t > 1):
        cnt[t] += 1

ans = 1



for d in range(2, N + 1):
    if cnt[d]:
        ans *= (cnt[d] + 1)
        ans %= MOD

print(ans)

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

primes=[]
is_prime = [True]*(N+1)
is_prime[0]=is_prime[1]=False
i=2
for i in range(N+1):
    if is_prime[i]:
        primes.append(i)
        j=i*2
        while j <= N:
            is_prime[j]=False
            j+=i

factor_num=dict()
for p in primes:
    factor_num[p]=0
for n in range(2,N+1):
    for p in primes:
        m=n
        while m:
            if m%p:
                break
            factor_num[p]+=1
            m//=p

ans=1
for f in factor_num.values():
    ans=ans*(f+1)%MOD

print(ans)

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

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[i] = cnt
            

    if temp != 1:
        arr[temp] = 1

    if arr == []:
        arr[n] = 1

    return arr

ans = {}
for i in range(1, N+1):
    arr = factorization(i)
    for key, value in arr.items():
        if key in ans:
            ans[key] += value
        else:
            ans[key] = value

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

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

Solution (Python):
isP = [True for _ in range(1005)]
isP[0] = isP[1] = False
for i in range(2, 1005):
  for j in range(2, 1005):
    if i * j >= 1005:
      break
    isP[i*j] = False
P = []
for i in range(1005):
  if isP[i]:
    P.append(i)
N = int(input())
ans = 1
for p in P:
  if p > N:
    continue
  else:
    k = p
    t = 1
    while k <= N:
      t += N // k
      k *= p
    ans *= t
print(ans % 1000000007)

Solution (Python):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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



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=one_int()

dicts={}
for i in range(2,N+1):
    lists = factorization(i)
    for item in lists:
        if item[0] != 1:
            if item[0] in dicts:
                dicts[item[0]] += item[1]
            else:
                dicts[item[0]] = item[1]

div=10**9 + 7
ans=1

for k,v in dicts.items():
    ans *= (v+1)%div

print(ans%div)

Solution (Python):

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


N = int(input())

ans_dict = {}
for i in range(2, N + 1):
    buf = primeFactorize(i)

    for j in buf:
        if not j in ans_dict:
            ans_dict[j] = 1
        else:
            ans_dict[j] += 1

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

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

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

pn=[2];A=1000
for L in range(3,A):
  chk=True
  for L2 in pn:
    if L%L2 == 0:chk=False
  if chk==True:pn.append(L)

mul = [1 for i in range(1001)]
for i in range(1,N+1):
  for j in pn:
    if j > i:
      break
    temp = i
    while True:
      if temp%j == 0:
        temp /= j
        mul[j] += 1
        continue
      else:
        break

ans = 1
for i in range(1001):
  ans *= mul[i]
  
print(ans%(7+10**9))

Solution (Python):
n = int(input())
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
d = {}
for i in range(2, n+1):
  a = factorization(i)
  for i in a:
    if i[0] not in d.keys():
      d[i[0]] = i[1]
    else:
      d[i[0]] += i[1]
ans = 1
for value in d.values():
  ans *= value+1
print(ans%(10**9+7))

Solution (Python):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30


def hurui(n):
    is_prime = [0] * (10**5)
    for i in range(2, n+1):
        is_prime[i] = 1
    for i in range(2, n+1):
        if is_prime[i] == 1:
            j = i*2
            while j <= n:
                is_prime[j] = 0
                j += i
    return is_prime

def main():
    n = int(input().strip())
    is_prime = hurui(n)
    ans = 1
    for i in range(2, n+1):
        if is_prime[i] == 1:
            c = 0
            for j in range(i, n+1):
                p = j
                while p % i == 0:
                    p //= i
                    c += 1
            ans *= (c+1)
            ans %= (10**9+7)
    print(ans)
if __name__ == '__main__':
    main()

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

mod = 10**9+7

dic = {}
L = [1]*(N+1)
L[0] = 0
L[1] = 0
for i in range(2, N+1):
    j = 2
    while i*j < N+1:
        L[i*j] = 0
        j += 1
        
for i in range(N+1):
    if L[i] == 1:
        dic[i] = 0

if N > 1:
    for i in range(2, N+1):
        j = 2
        while i > 1:
            if L[j] == 1 and i%j == 0:
                dic[j] += 1
                i //= j
            else:
                j += 1
            
    ans = 1
    for i in dic:
        if dic[i] > 0:
            ans *= (dic[i]+1)
            ans %= mod
else:
    ans = 1
        
print(ans)

Solution (Python):


n = int(input())

fct = [1]*(n+1)
fct[1] = 0
fct[0] = 0
mod = 10**9+7

sq = int(n**(1/2))+5

for i in range(2,sq):
    for j in range(2,(n//i)+10):
        if i*j<=n:
            fct[i*j] = 0
            
            


prm = []

for i in range(n+1):
    if fct[i]:
        prm.append(i)

ind = []

for p in prm:
    tmp = 0
    tmp2 = n
    while tmp2:
        tmp2//=p 
        tmp += tmp2 
    ind.append(tmp)
ans = 1
for i in ind:
    ans *= (i+1)
    ans %= mod


print(ans)

Solution (Python):
import bisect
def prime(n):
  prime_table = [2]
  for i in range(3,n+1):
    f = 1
    for j in prime_table[:bisect.bisect_right(prime_table,int(i**0.5))]:
      if i % j == 0:
        f = 0
        break
    if f:
      prime_table.append(i)
  return prime_table

n = int(input())
prime = prime(10**3)
l = [0] * len(prime)
for i in range(1,n+1):
  for j in range(len(prime)):
    while i % prime[j] == 0:
      i = i // prime[j]
      l[j] += 1
a = 1
for i in l:
  a = (a * (i+1)) % (10**9+7)
print(a)

Solution (Python):
from collections import defaultdict

N = int(input())
r = 10 ** 9 + 7
d = defaultdict(int)
for n in range(1, N+1):
    temp = n
    i = 2
    while i ** 2 <= temp:
        while temp % i == 0:
            d[i] += 1
            temp //= i
        i += 1
        if temp < i:
            break
    if temp != 1:
        d[temp] += 1
ans = 1
if d != {}:
    for v in d.values():
        ans = (ans * (v + 1)) % r
print(ans)

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

MOD = 10**9+7

NN = [0 for _ in range(1001)]
AA = [0 for _ in range(1001)]


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

ans = 1
for i in range(1, N+1):
    chin = factorization(i)
    
    
    for x,y in chin:
        AA[x] += y
for i in range(2, N+1):
    if AA[i] > 0:
        
        ans *= (AA[i]+1) % MOD
        ans %= MOD
print(ans)

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

def fact(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

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

arr = [0 for _ in range(1001)]

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

    for j in range(len(fact(i))):
        arr[fact(i)[j][0]] += fact(i)[j][1]

ans = 1
for i in range(2,1001):
    if arr[i] > 0:
        ans *= arr[i] +1
    if ans > 1000000007:
        ans % 1000000007

print(ans % 1000000007)

Solution (Python):
import sys
N=int(input())
if N == 1:
    print(1)
    sys.exit()
lim=10**9+7
import numpy as np
def seachPrimeNum(N):
    max_ = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max_:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

ans = 1
l=seachPrimeNum(N)

for p in l:
    temp=0
    k=1
    while True:
        if p**k>N:
            break
        temp += N//(p**k)
        k+=1
    ans = (ans * (temp + 1)) % lim
    
print(ans)

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

result = [0 for i in range(n+1)]

for i in range(1, n+1):
    for j in range(2, i+1):
        while i%j == 0:
            result[j] += 1
            i //= j
        if i == 1:
            break
r = 1
for i in range(n+1):
    r *= result[i]+1
    r %= 10**9 + 7
print(r)

Solution (Python):
n=int(input())
cnt=[]
def prime(x):
    for i in range(2,x+1):
        while x%i==0:
            x/=i
            cnt.append(i)   
           
if n==1:
    print(1)
else:
    li=[]
    for j in range(2,n+1):
        prime(j)
    cnt.sort() 
    
    ans=[1]*len(set(cnt))
    x=-1
    for k in cnt:
      if k in li:
        ans[x]+=1
      else:
        li.append(k)
        x+=1
        ans[x]+=1
    y=1
    for l in ans:
      y*=l
        
    print(y%(10**9+7))

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

def prime_factorization(n):
    '''
    素因数分解を求める

    Parameters:
    n : int
        求める数
    
    Returns:
    r : list
        素因数分解の結果
    '''
    r=[1]*(n+1)
    for i in range(1,n+1):
        for j in range(2,i+1):
            while i % j == 0:
                r[j] += 1
                i //= j
    
    return r

r = prime_factorization(N)
ans = 1
for i in r:
    ans *= i
    ans %= mod

print(ans)

Solution (Python):
"素因数分解のライブラリ"
from collections import Counter


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


N = int(input())
MOD = 1000000007
numbers = []
for i in range(1, N+1):
    numbers.extend(prime_factorize(i))

count_numbers = Counter(numbers)
ans = 1
for n in count_numbers.values():
    ans *= ((n+1) % MOD)

print(ans % MOD)

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


mod=10**9+7
n=int(input())
cnt={}
for i in range(1,n+1):
    for j in prime_factorize(i):
        if j not in cnt:cnt[j]=1
        else:cnt[j] +=1

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

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

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

result = [0 for i in range(n+1)]

for i in range(1, n+1):
    for j in range(2, i+1):
        while i%j == 0:
            result[j] += 1
            i //= j
        if i == 1:
            break
r = 1
for i in range(n+1):
    r *= result[i]+1
    r %= 10**9 + 7
print(r)

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

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())
MOD = 10 ** 9 + 7
d = defaultdict(int)
for i in range(2, N+1):
    ar = factorization(i)
    for k, v in ar:
        d[k] += v
answer = 1
for k, v in d.items():
    answer *= (v+1)
    answer %= MOD
print(answer)

Solution (Python):
l =    [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
n = int(input())
for i in l:
  temp = n
  c = 1
  while temp >= i:
    temp //= i
    c += temp
  ans *= c
print(ans%(10**9+7))

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

n = int(input())

e = [0] * (10 ** 3 + 1)
for x in range(1, n + 1):
    div = 2
    cnt = 0
    while x % div == 0:
        x //= div
        cnt += 1
    if cnt > 0:
        e[div] += cnt

    for div in range(3, int(n ** 0.5) + 1, 2):
        cnt = 0
        while x % div == 0:
            x //= div
            cnt += 1
        if cnt > 0:
            e[div] += cnt

    if x > 1:
        e[x] += 1

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

Solution (Python):
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = math.factorial(int(input()))
    i = 2
    ans = 1
    while i * i < N:
        cnt = 1
        while N % i == 0:
            cnt += 1
            N //= i
        ans *= cnt
        i += 1
    if N != 1:
        ans *= 2

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


if __name__ == '__main__':
    main()

Solution (Python):
import collections

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

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

F = []
for i in range(2,N+1):
  F[len(F):len(F)] = prime_factorize(i)

c = collections.Counter(F)

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

Solution (Python):
from collections import defaultdict
d=defaultdict(int)
n=int(input())
def prime(n):
  if n==2:
    return True
  if n==3:
    return True
  for i in range(2,int((n)**(1/2))+1):
    if n%i==0:
      return False
  return True
plist=[]
for i in range(2,n+1):
  if prime(i):
    plist.append(i)
for i in range(1,1+n):
  num=i
  for j in plist:
    countp=0
    while num%j==0:
      num=num//j
      countp+=1
    d[j]+=countp
ans=1
for i in d:
  ans=(ans*(d[i]+1))%(10**9+7)
print(ans)

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

def bunkai(n):
  a=[]
  while n%2==0:
    n//=2
    a.append(2)
  f=3
  while f*f<=n:
    if n%f==0:
      n//=f
      a.append(f)
    else:
      f+=2
  if n!=1:
    a.append(n)
  return(collections.Counter(a))
  
l=collections.Counter()
for n in range(1,N+1):
  l+=bunkai(n)
  
ans=1
for i in l.values():
  ans=(ans*(i+1)%mod)%mod
  
print(ans)

Solution (Python):
import sys
import math

def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    Q = [0 for k in range(N+1)]
    for M in range(1,N+1):
        k = 2
        while k*k <= M:
            if M%k == 0:
                M //= k
                Q[k] += 1
            else:
                k += 1
        if M > 1:
            Q[M] += 1
    ans = 1
    for k in range(N+1):
        ans *= Q[k]+1
        ans %= 10**9 + 7
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict

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

def primeCount(N):
    R = int(N**(0.5)) + 1  
    primes = {}  
    n = N
    for num in range(2, R):
        primes[num] = 0
        while n % num == 0:
            n //= num
            primes[num] += 1
    if n > 1 :
        primes[n] = 1
    return { key : val for key, val in primes.items() if val > 0}  

primes = defaultdict(int)
for i in range(1, N + 1):
    ps = primeCount(i)
    for p, c in ps.items():
        primes[p] += c

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

print(ans % MOD)

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

from collections import Counter
def factorize(n):
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1
    return d

factors = Counter()
for n in range(1,N+1):
    factors += factorize(n)

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

Solution (Python):
import sys
input=sys.stdin.readline


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

def main():
    N = int(input())
    
    
    d = dict()
    for n in range(1, N+1):
        for p in prime_factorize(n):
            if p in d:
                d[p] += 1
            else:
                d[p] = 1
    ans = 1
    for i in d.values():
        ans *= (i+1)
        ans %= (10**9+7)

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    d = collections.defaultdict(int)
    for i in range(1, n + 1):
        t = i
        for j in range(2, i + 1):
            while True:
                if t % j == 0:
                    d[j] += 1
                    t //= j
                else:
                    break
    t = 1
    for k, v in d.items():
        t = t * (v + 1) % (10 ** 9 + 7)
    print(t)


if __name__ == '__main__':
    slove()