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())
ans = 1
mod = 1000000007

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

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

for i in range(2,n+1):
    if a[i]>0:
        ans *= a[i]+1
        ans %= mod

print(ans)

Solution (Python):
import math

N = int(input())



def trial_division(n):
    
    factor = []
    
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    
    if not factor:
        return 'prime number'
    else:
        factor.append(n)
        return factor

prime_cnt = {}
for i in range(1, N + 1):
  ps = trial_division(i)
  if ps == "prime number":
    ps = [i]
  for d in ps:
    if d == 1:
      continue
    if d in prime_cnt:
      prime_cnt[d] += 1
    else:
      prime_cnt[d] = 1
      

  
ans = 1
for d in prime_cnt:
  ans *= prime_cnt[d] + 1
  ans %= 1000000007
  
print(ans)

Solution (Python):

























































import math
def prime(x):
  p = {}
  cnt = 2
  Flag = True
  while Flag:
    last = math.ceil(x ** 0.5) 
    if cnt > last:
      break
    for i in range(cnt, last + 1):
      if x % i == 0:
        x //= i
        p[i] = 1
        cnt = i + 2
        while x % i == 0:
          x //= i
          p[i] += 1
        cnt = i + 1
        break
      if i == last:
        Flag = False
  if x != 1:
    p[x] = 1
  return p

N = int(input())
R = {}
MOD = 10 ** 9 + 7
for i in range(1, N + 1):
  t = prime(i)
  for i in t.keys():
    if i not in R:
      R[i] = t[i]
    else:
      R[i] += t[i]
      
ans = 1
for i in R.values():
  ans = ans * (i + 1) % MOD

print(ans)

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

MOD = 10 ** 9 + 7

pfac = [1] * (N + 1)

for i in range(1, N + 1) :
    j = i
    while j % 2 == 0 :
        j //= 2
        pfac[2] += 1
    
    k = 3
    while j > 1 :
        while j % k == 0 :
            j //= k
            pfac[k] += 1
        k += 2
    
ret = 1
for i in range(2, N + 1) :
    ret *= pfac[i]
    ret %= MOD
    
print(ret)

Solution (Python):
def power(x,y):
    if x%y != 0:
        return 0
    else:
        return 1+power(x/y,y)


def main():
    n = int(input())
    prime=[]
    fact = {}
    num_list = [i for i in range(2,n+1)]
    i = 0
    ans = 1
    if n ==1:
        print(ans)
        exit()
    mod = 10**9+7
    while i <=n**0.5:
        i = num_list.pop(0)
        prime.append(i)
        for j in num_list:
            if j%i ==0:
                num_list.remove(j)
    prime = prime + num_list

    for i in range(1,n+1):
        for j in prime:
            if i <j:
                break
            elif j in fact.keys():
                fact[j] += power(i,j)
            else:
                fact[j] = power(i,j)
    for i in fact.values():
        ans *= (i+1)
        ans %= mod
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):


N = int(input())

ans = 1

dic = {}
ori = [2]

dic[2] = 0

for i in range(998):

    i += 2

    flag = True

    for j in ori:

        if i % j == 0:
            flag = False

    if flag:
        dic[i] = 0
        ori.append(i)


for i in range(N):

    i += 1

    for j in ori:

        cnt = 1

        while True:

            if i % (j ** cnt) != 0:
                break

            cnt += 1

        dic[j] += cnt-1

for i in dic:

    ans *= (dic[i] + 1)

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

Solution (Python):
n = int(raw_input())
sieve = [True for i in range(n+1)] 
for i in range(2, n+1):
    if sieve[i] == True:
        for j in range(i+i, n+1, i):
            sieve[j] = False
res = 1

for i in range(2, n+1):
    m = 1
    if sieve[i] == False:
        continue
    for j in range(i, n+1):
        j2 = j
        while j2 % i == 0:
            m += 1
            j2 /= i
    res = (res * m) % (10**9+7)
print res

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

N = int(input())

def f(n):
    prime = [i for i in range(2, 1000)]
    
    index = 0
    while True:
        p = prime[index]
        
        prime = [v for v in prime if v == p or v % p != 0]
        index += 1
        
        if len(prime) <= index:
            break
    
    return prime

prime = f(N)

def f2(n):
    l = {}
    
    for v in prime:
        while n % v == 0:
            n = n // v
            if l.get(v) == None:
                l[v] = 0
            l[v] += 1
    return l
            
re = {}

for i in range(2, N + 1):
    for k, v in f2(i).items():
        if re.get(k) == None:
            re[k] = 0
        re[k] += v
        
result = 1
for _, v in re.items():
    result *= v + 1
print(result % (10 ** 9 + 7))

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

def prime_factor(n):
    d = defaultdict(int)
    for i in range(2, n + 1):
        if i * i > n:
            break
            
        while n % i == 0:
            d[i] += 1
            n //= i
            
    if n != 1:
        d[n] = 1
            
    return d

d = defaultdict(int)
for i in range(1, N + 1):
    for j, v in prime_factor(i).items():
        d[j] += v

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

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

li=[]
li2=[]

for i in range(2,n+1):
    tmp=math.factorial(n)
    flag=1
    for j in range(len(li)):
        if i%li[j]==0:
            flag=0
            break
    if flag==1:
        li.append(i)
        li2.append(0)
        while tmp%i==0:
            li2[len(li)-1]+=1
            tmp=tmp//i
ans=1


for i in range(len(li2)):
    ans*=li2[i]+1
print(ans%waru)

Solution (Python):
import math
from collections import defaultdict

N = int(input())

d = defaultdict(int)

def division(n,d):
    flag = True
    tmp = n // 2 + 1
    for num in range(2, tmp):
        while n % num == 0:
            flag = False
            n //= num
            d[num] += 1

    if flag:
        d[n] += 1

    return

for n in range(2,N+1):
    division(n,d)

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

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

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

Solution (Python):
from math import factorial
N = int(input())

def pdwn(n):
    i=2
    z={}
    while i*i<=n:
        while n%i==0:
            n//=i
            z[i] = z.get(i,0) + 1
        i+=1
    if n>1:z[n] = z.get(n,0) + 1
    g = 1
    for y in z.keys():g *= z[y] + 1
    return g

print(pdwn(factorial(N))%(10**9+7))

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


sosu = "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"
ls = list(map(int,sosu.split()))
def solve(n,k,cnt):
    if n%k!=0:
        return cnt
    else:
        return solve(n//k,k,cnt+1)


from collections import defaultdict
d = defaultdict(int)
for i in range(1,n+1):
    for j in ls:
        d[j] += solve(i,j,0)

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

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

Solution (Python):
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18


def get_factors(n):
    """
    素因数分解
    :param int n:
    :rtype: list of int
    """
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret


N = int(sys.stdin.readline())
MOD = 10 ** 9 + 7

factors = []
for n in range(2, N + 1):
    factors.extend(get_factors(n))



counts = np.bincount(factors)
ans = 1
for e in counts[counts > 0]:
    ans = ans * (e + 1) % MOD
print(ans)

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

import math
from collections import defaultdict
d = defaultdict(int)

def trial_division(n,d):
    flg=True
    
    tmp = n//2 + 1
    for num in range(2,tmp):
        while n % num == 0:
            flg=False
            n //= num
            d[num]+=1

    
    if flg:
        d[n]+=1

    return

for n in range(2,N+1):
    trial_division(n,d)

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

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

Solution (Python):

def count_divisors(num: int) -> int:
    """
    Compute how many divisors a number has.
    arr (2D array): prime factors and how many times used
    e.g. n = 2^a * 3^b -> [(2, a), (3, b)]
         res = (a + 1) * (b + 1)
    """
    max_prime = 0
    dic = {}  

    
    cnt = 0
    while num % 2 == 0:
        num //= 2
        cnt += 1
    if cnt > 0:
        max_prime = 2
        dic[max_prime] = cnt

    
    cnt = 0
    for i in range(3, int(num ** 0.5) + 1, 2):
        cnt = 0
        while num % i == 0:
            num //= i
            max_prime = i
            cnt += 1
        if cnt > 0:
            dic[max_prime] = cnt

    
    if num > 2:
        max_prime = num
        dic[max_prime] = 1

    return dic


def main():
    n = int(input())
    MOD = 10 ** 9 + 7
    f = {}
    for i in range(2, n + 1):
        for j, k in count_divisors(i).items():
            if j not in f:
                f[j] = 0
            f[j] += k
    ans = 1
    for i in f.values():
        ans = (ans * (i + 1)) % MOD
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
ans = 1
mod = 10**9 + 7
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]
Sieve = [0]*(N+1)

for i in range(2,N+1):
    temp = i
    for p in prime:
        if p > temp:
            break
        while temp%p == 0:
            Sieve[p] += 1
            temp /= p

for s in Sieve:
    if s > 0:
        ans *= s+1
        ans %= mod

print(ans)

Solution (Python):
n = int(input())
d = [0] * (n+1)
mod = 1000000007
for i in range(1, n+1):
    num = i
    cnt = 0
    m = 2
    while(num != 1):
        while(num % m == 0):
            cnt += 1
            num /= m
        d[m] += cnt
        m += 1
        cnt = 0
ans = 1
for i in range(1,n+1):
    if(d[i] == 0):
        continue
    
    ans *= (d[i]+1)
    ans %= mod

print(ans)

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





factor = dict()

def trial_division(n):
    tmp = int(math.sqrt(n)) + 1
    a = n
    flag = False
    for num in range(2, tmp):
        while a%num == 0:
            a //= num
            if num in factor:
                factor[num] += 1
            else:
                factor[num] = 1
            flag = True
    
    if not flag and n != 1:
        factor[n] = 1
    if flag:
        if a in factor:
            factor[a] += 1
        else:
            factor[a] = 1

    
    return True

for i in range(1, N+1):
    trial_division(i)

ans = 1
for i in factor:
    if i == 1:
        pass
    else:
        ans *= (factor[i]+1)
print (ans%(7 + 10 ** 9))

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


N = int(input())

sosuu = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
for i in range(2, N+1):
    if i % 2 == 0 or i % 3 == 0 or i == 5 or i % 7 == 0 or i % 11 == 0 or i%13 == 0 or i%17 == 0\
            or i%19 == 0 or i%23 == 0 or i%29 == 0 or i%31 == 0 or i%37 == 0:
        continue
    for j in range(2,i+1):
        if j == i:
            sosuu.append(i)
        if i % j == 0:
            break

soinsuu_num = [0 for i in range(len(sosuu))]

for i in range(1, N+1):
    if i == 1:
        continue
    temp = i
    for j in range(len(sosuu)):
        while temp % sosuu[j] == 0 and temp != 1:
            soinsuu_num[j] += 1
            temp = Decimal(temp) / Decimal(sosuu[j])
        if temp == 1:
            break

ans = 1
for i in soinsuu_num:
    if i != 0:
        ans = ans * (i + 1) % mod

print(ans)

Solution (Python):
x=int(input())
def divisor(a):
	cnt=0
	for i in range(1, int(a**0.5)+1):
		if a%i==0:
			cnt+=2
	return cnt
ans=1
mod = 10**9 +7
dic={i:0 for i in range(2,x+1)}
for a in range(2,x+1):
	for i in range(2, int(a**0.5)+1):
		while a%i==0:
			dic[i]+=1
			a//=i
	if a!=1:dic[a]+=1
A=[i for i in dic.values() if i!=0]
ans=1
for i in A:
	ans=ans*(i+1)%mod

print(ans)

Solution (Python):
n=int(input())
fact=1
for i in range(2,n+1):
	fact*=i
sieve=[0]*2+[1]*100000
primes=[]
for i,e in enumerate(sieve):
	if sieve[i]==1:
		primes.append(i)
		for j in range(i*2,len(sieve),i):
			sieve[j]=0
ans=1
MOD=10**9+7
for prime in primes:
	if fact%prime==0:
		count=0
		while fact%prime==0:
			fact=fact//prime
			count+=1
		ans=(ans*(count+1))%MOD
print(ans%MOD)

Solution (Python):
import math
import random


class Prime:
    seed_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]

    def is_prime(self, n):
        """
        prime test (hybrid)

        see also: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """
        is_prime_common = self.is_prime_common(n)
        if is_prime_common is not None:
            return is_prime_common

        if n < 2000000:
            return self.is_prime_brute_force(n)
        else:
            return self.is_prime_miller_rabin(n)

    def is_prime_common(self, n):
        if n == 1: return False
        if n in Prime.seed_primes: return True
        if any(map(lambda x: n % x == 0, self.seed_primes)): return False

    def is_prime_brute_force(self, n):
        """
        brute force prime test
        use with is_prime_common if you want to skip seed_primes

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

    def is_prime_miller_rabin(self, n):
        """
        miller rabin prime test
        use with is_prime_common if you want to skip seed_primes

        see also
            algorithm: https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
            implementation: https://qiita.com/srtk86/items/609737d50c9ef5f5dc59
            improvement: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """

        d = n - 1
        while d & 1 == 0:
            d >>= 1

        
        witnesses = self.get_witnesses(n)
        

        for w in witnesses:
            y = pow(w, d, n)

            while d != n - 1 and y != 1 and y != n - 1:
                y = (y * y) % n
                d <<= 1

            if y != n - 1 and d & 1 == 0:
                return False

        return True

    def get_witnesses(self, num):
        def _get_range(num):
            if num < 2047:
                return 1
            if num < 1373653:
                return 2
            if num < 25326001:
                return 3
            if num < 3215031751:
                return 4
            if num < 2152302898747:
                return 5
            if num < 3474749660383:
                return 6
            if num < 341550071728321:
                return 7
            if num < 3825123056546413051:
                return 9
            return 12

        return self.seed_primes[:_get_range(num)]

    def gcd(self, a, b):
        if a < b:
            return self.gcd(b, a)
        if b == 0:
            return a
        while b:
            a, b = b, a % b
        return a

    @staticmethod
    def f(x, n, seed):
        """
        pseudo prime generator
        :param x:
        :param n:
        :param seed:
        :return: pseudo prime
        """
        p = Prime.seed_primes[seed % len(Prime.seed_primes)]
        return (p * x + seed) % n

    def find_factor(self, n, seed=1):
        """
        find one of factor of n
        this function is based to Pollard's rho algorithm

        see also
            algorithm: https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm
            implementation: https://qiita.com/gushwell/items/561afde2e00bf3380c98

        :param n:
        :param seed:
        :return: factor
        """
        if self.is_prime(n):
            return n

        x, y, d = 2, 2, 1
        count = 0
        while d == 1:
            count += 1
            x = self.f(x, n, seed)
            y = self.f(self.f(y, n, seed), n, seed)
            d = self.gcd(abs(x - y), n)

        if d == n:
            return self.find_factor(n, seed+1)
        return self.find_factor(d)

    def find_factors(self, n):
        primes = {}
        if self.is_prime(n):
            primes[n] = 1
            return primes

        while n > 1:
            factor = self.find_factor(n)

            primes.setdefault(factor, 0)
            primes[factor] += 1

            n //= factor

        return primes





from collections import Counter

N = int(input())

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

mod = int(1e9+7)
prime = Prime()

solver_dict = {}
for i in range(1,N):
  pre_dict = prime.find_factors(i+1)
  solver_dict = dict(Counter(solver_dict) + Counter(pre_dict))



lst = list(solver_dict.items())


ans = 1
for i in range(len(lst)):
  ans = ans * (lst[i][1] + 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 I(): return int(input())
def LS(): return input().split()
def S(): return input()


def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)
  
  if n!=1:
    l.append(n)
  
  return l

def main():
  n=I()

  l=[0]*1001

  for i in range(2,n+1):
    y=getPrimeList(i)
    for x in y:
      l[x]+=1

  sm=1
  for x in l:
    if x!=0:
      sm*=x+1

  return sm%mod

print(main())

Solution (Python):
from collections import defaultdict

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

nums = []
for i in range(2, N+1):
    for j in range(2, i+1):
        if i % j == 0:
            if i == j:
                nums.append(i)
            else:
                break

c = 0
count = defaultdict(int)
for i in range(2, N+1):
    for n in nums:
        now = i
        while now % n == 0:
            count[n] += 1
            now //= n

ans = 1
for n in count.values():
    ans = ans * (n+1) % p
print(ans)

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

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

Solution (Python):

from math import sqrt
from collections import defaultdict
def furui(N):
    primes = []
    nums = list(range(2,N+100))
    limit = sqrt(N+1)

    while True:
        p = nums[0]
        if p > limit:
            primes += nums
            return primes

        primes.append(p)
        nums = [num for num in nums if num % p != 0]




N = int(input())
DIV = 10**9 + 7
primes = furui(N)
di = defaultdict(lambda :0)
for i in range(2,N+1):
    temp = i
    for p in primes:
        while True:
            if temp % p == 0:
                di[p] += 1
                temp /=p
            else:
                break

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

print(ans%DIV)

Solution (Python):
import numpy as np

n=int(input())

def fact(m):
    factor1=[0] * m
    for j in range(2,m+1):
        factor = [0] * j
        for i in range(2,int(np.sqrt(j)+2)):
            while j % i == 0:
                j//=i
                factor[i-1]+=1
        factor[j-1]+=1
        for k in range(len(factor)):
            factor1[k]+=factor[k]
    return factor1
ans=1
mod=1000000007
for i in fact(n)[1:]:
    if i!=0:
        ans*=(i+1)
        ans%=mod

print(ans)

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


if n==1:
    print(1)
    import sys
    sys.exit()

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

prime_list = primes(n)
prime_cnt = dict([(k,0) for k in prime_list])
from decimal import Decimal

for k in range(2,n+1):
    k = Decimal(k)
    for j in prime_list:
        j=Decimal(j)
        while k%j==0:
            prime_cnt[j]+=1
            k = k/j
        if k==1:
            break

import functools
import operator


print(functools.reduce(operator.mul, [v+1 for v in prime_cnt.values()])%(10**9+7))

Solution (Python):
from collections import defaultdict

def prime_factorization(n):
    '''
    Trial division.
    Input: 
        n : a positive integer
    Output:
        a dictionary of 
    '''
    result = defaultdict(int)
    if n < 2:
        return result
    while n % 2 == 0:
        result[2] += 1
        n //= 2
    p = 3
    while p*p <= n:
        while n % p == 0:
            n //= p
            result[p] += 1
        p += 2
    if n > 1:
        result[n] += 1
    return result

N = int(input())
MOD = 10**9 + 7
factors = defaultdict(int)
for i in range(2, N+1):
    fac = prime_factorization(i)
    for p, n in fac.items():
        factors[p] += n
ans = 1
for _, n in factors.items():
    ans = (ans * (n+1)) % MOD
print(ans)

Solution (Python):
from collections import defaultdict

def prime_factorization(n):
    '''
    Trial division.
    Input: 
        n : a positive integer
    Output:
        a dictionary of 
    '''
    result = defaultdict(int)
    if n < 2:
        return result
    while n % 2 == 0:
        result[2] += 1
        n //= 2
    p = 3
    while p*p <= n:
        while n % p == 0:
            n //= p
            result[p] += 1
        p += 2
    if n > 1:
        result[n] += 1
    return result

N = int(input())
MOD = 10**9 + 7
factors = defaultdict(int)
for i in range(2, N+1):
    fac = prime_factorization(i)
    for p, n in fac.items():
        factors[p] += n
ans = 1
for _, n in factors.items():
    ans = (ans * (n+1)) % MOD
print(ans)

Solution (Python):
a=int(input())
yakusuu=[[],[]]

for i in range(2,a+1):
    while not i==1:
        for n in range(2,i+1):
            if i%n==0:
                i=int(i/n)
                if n not in yakusuu[0]:
                    yakusuu[0].append(n)
                    yakusuu[1].append(1)
                else:
                    yakusuu[1][yakusuu[0].index(n)]+=1
                break
count=1
for i in yakusuu[1]:
    count*=i+1

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

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


def so_bunkai(num, dicts):
    N = num
    num = int(num**(1 / 2) // 1)
    for i in range(2, num + 2):
        while N % i == 0:
            N /= i
            if i in dicts:
                dicts[i] += 1
            else:
                dicts[i] = 1
    if N != 1:
        if N in dicts:
            dicts[int(N)] += 1
        else:
            dicts[int(N)] = 1
    return dicts


ans_dict = {}
for i in range(1, N + 1):
    ans_dict = so_bunkai(i, ans_dict)
    
asd = 10**9 + 7
ans = 1
for d in ans_dict:
    ans *= (ans_dict[d] + 1)
    ans %= asd

print(ans)

Solution (Python):
import math
def trial_division(n):
    
    factor = []
    
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    
    if not factor:
        return [n]
    else:
        factor.append(n)
        return factor

mod = 10**9+7        
N = int(input())
di = {}
ans = 1
for i in range(1,N+1):
    l = trial_division(i)
    for j in l:
        if(j in di):
            di[j]+=1
        else:
            di[j]=1
for i in di:
    if(i==1):
        continue
    ans *= (di[i]+1)
    ans %= mod
print(ans)

Solution (Python):


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

    """考え方
    ・6の約数の個数は？
    6を素因数分解すると
    6 = 2 * 3
    2^(k1) * 3^(k2) （0<= k1,k2 <= 1）の組み合わせが約数（1,2,3,6）

    この約数の個数を求める問題は、「|k1|個のボールと|k2|個のボールを取り出す組み合わせ問題」と同じ。

    というふうに、まず素因数分解をして因数のknをそれぞれ求めて、その組合せの数を求めれば良い。
    """

    dic = {}  

    for n in range(2, N+1):
        num = n
        i = 2
        while True:
            if i > num: break

            if num%i == 0:
                num = num / i
                if not i in dic: dic[i] = 1
                dic[i] += 1
                continue
            else:
                i += 1
                continue

    ans = 1
    for key, value in dic.items():
        ans *= value
        ans %= MOD

    print(ans)


if __name__ == "__main__":
    solve()

Solution (Python):


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

    """考え方
    ・6の約数の個数は？
    6を素因数分解すると
    6 = 2 * 3
    2^(k1) * 3^(k2) （0<= k1,k2 <= 1）の組み合わせの数が約数（1,2,3,6）

    これは、「|k1|個のボールと|k2|個のボールを取り出す組み合わせ問題」と同じ。

    というふうに、まず素因数分解をして因数のknをそれぞれ求めて、その組合せの数を求めれば良い。
    """

    dic = {}

    for n in range(2, N+1):
        num = n
        i = 2
        while True:
            if i > num: break

            if num%i == 0:
                num = num / i
                if not i in dic: dic[i] = 1
                dic[i] += 1
                continue
            else:
                i += 1
                continue

    ans = 1
    for key, value in dic.items():
        ans *= value
        ans %= MOD

    print(ans)


if __name__ == "__main__":
    solve()

Solution (Python):
def shave(n):
    n_root = int(n**0.5)
    candidate = [i for i in range(3,n+1,2)]
    for i in range(3,n_root+2,2):
        candidate = [ j for j in candidate if j == i or j % i != 0]   
    candidate = [2] + candidate
    return candidate

mod = 10**9+7
n = int(input())
factor_list = shave(n)
lf = len(factor_list)
num_list = [ 0 for i in range(lf) ]

ans = 1

if n > 1:
	k = 0
	for i in factor_list:
		a = i
		
		for j in range(10):
			if a > n:
				break
			else:
				num_list[k] += (n // a)
				a *= i
		k += 1

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

print(ans)

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

n = int(input())
mp = {}
memo = [0 for i in range(n+1)]

for i in range(2, n+1):
    x = i
    for j in range(2, x+1):
        while x % j == 0:
            x /= j
            if memo[j] == 0:
                mp[j] = 0
                memo[j] = 1
            mp[j] += 1

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

print(ans % mod)

Solution (Python):

from collections import defaultdict


MOD = 1000000007

def fact(n):
  ret = defaultdict(lambda:0)
  m = 2
  while n > 1:
    if n%m == 0:
      ret[m] += 1
      n //= m
    else:
      m += 1
  return ret


N = int(input())
dct = defaultdict(lambda:0)
for i in range(1,N+1):
  dct_i = fact(i)
  for r in dct_i:
    dct[r] += dct_i[r]

ans = 1
for k in dct:
  ans = (ans*(dct[k]+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 I(): return int(input())
def LS(): return input().split()
def S(): return input()


def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)
  
  if n!=1:
    l.append(n)
  
  return l

def main():
  l=[0]*1001

  n=I()

  for i in range(2,n+1):
    x=getPrimeList(i)
    for j in x:
      l[j]+=1

  sm=1
  for i in l:
    sm*=i+1

  return sm%mod

print(main())

Solution (Python):
import math
N = int(input())
N_kaizyo = math.factorial(N)
sosuu_list = []
count = 1
ans = 1
def check_sosuu(x):
    i = math.floor(math.sqrt(x))
    for j in range(2,i + 1):
        if (x % j == 0):
            return False

    return True

for i in range(2, N + 1):
    if (check_sosuu(i)):
        sosuu_list.append(i)

for sosuu in sosuu_list:
    while N_kaizyo % sosuu == 0:
        N_kaizyo //= sosuu
        count += 1
    ans *= count
    count = 1

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

Solution (Python):
N = int(input())
numberlist = []
for i in range(2, N+1):
	numberlist.append(i)
prime = []
while numberlist != []:
	newnumberlist = []
	now = numberlist.pop(0)
	prime.append(now)
	while numberlist != []:
		x = numberlist.pop(0)
		if x%now != 0:
			newnumberlist.append(x)
	numberlist = newnumberlist
counter = []
for i in range(0, len(prime)):
	counter.append(1)
for i in range(1, N+1):
	m = i
	for j in range(0, len(prime)):
		if m == 1: break
		while m%prime[j] == 0:
			counter[j] += 1
			m = m // prime[j]
ans = 1
for i in range(0, len(counter)):
	ans = (ans*counter[i]) % 1000000007
print(ans)