Problem:


Score : 400 points

Problem Statement

For a positive integer X, let f(X) be the number of positive divisors of X.

Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Constraints

1 \leq N \leq 10^7

Input

Input is given from Standard Input in the following format:

N

Output

Print the value \sum_{K=1}^N K\times f(K).

Sample Input 1

4

Sample Output 1

23

We have f(1)=1, f(2)=2, f(3)=2, and f(4)=3, so the answer is 1\times 1 + 2\times 2 + 3\times 2 + 4\times 3 =23.

Sample Input 2

100

Sample Output 2

26879

Sample Input 3

10000000

Sample Output 3

838627288460105

Watch out for overflows.



Sample input:
4


Sample output:
23

Submission status: Accepted

Solution code:
N=int(input())
ans=0
for i in range(1,N+1):
  a=N//i
  ans+=(a*(a+1)*i)//2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for i in range(1 , N + 1):
  # 2,4,6,8,...
  last = N // i * i
  # i , last = n * i
  ans += (i + last) * (last // i) // 2

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  def f(d, n):
    m = n // d
    return m * (m+1) * d // 2
  print(sum([f(d, n) for d in range(1, n+1)]))
  
if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
n = int(input())
ans = 0

for j in range(1, n+1):
    a = n//j
    ans += a*(a+1)*j//2
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())

count = 0
for i in range(1, N+1):
    count += (N // i) * (i + i * (N//i)) // 2


print(count)

Submission status: Accepted

Solution code:
n = int(input())

def calc_sum(b, e):
    cnt = (e - b) // b + 1
    return (b + e) * cnt // 2

ans = 0
for i in range(1, n+1):
    ans += calc_sum(i, n // i * i)

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

cnt = [1] * (n + 1)
cnt[0] = 0
cnt[1] = 0

p = 2
while p  <= n // 2:
    for i in range(p*2, n+1, p):
        cnt[i] += 1
    p += 1

ans = 0
for i in range(1, n+1):
    # print(i, cnt[i]+1)
    ans += i * (cnt[i] + 1)

print(ans)

Submission status: Accepted

Solution code:
class Osa_k:
    def __init__(self, n_max):
        self.n_max = n_max
        self.min_factor = min_factor = list(range(n_max + 1))
        min_factor[2::2] = [2] * (n_max // 2)
        min_factor[3::6] = [3] * ((n_max + 3) // 6)
        for i in range(5, int(n_max ** .5) + 1, 2):
            if min_factor[i] == i:
                for j in range(i*i, n_max + 1, i):
                    if min_factor[j] == j:
                        min_factor[j] = i

    def __call__(self, n):
        min_factor = self.min_factor
        t = []
        while n > 1:
            if t and t[-1][0] == min_factor[n]:
                t[-1][1] += 1
            else:
                t.append([min_factor[n], 1])
            n //= min_factor[n]
        res = 1
        for _, i in t:
            res *= i + 1
        return res

P = Osa_k(10**7)
print(sum(i * P(i) for i in range(1, int(input()) + 1)))

Submission status: Accepted

Solution code:
N = int(input())
tot = 0
for i in range(1, N+1):
    m = N//i
    tot += i * (m * (m+1)) // 2
print(tot)

Submission status: Accepted

Solution code:
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def main():
    k = int(input())
    ans = 0
    for i in range(1, k+1):
        ans += k//i * (2 * i + (k//i - 1) * i) // 2
    print(ans)
main()

Submission status: Accepted

Solution code:
N = int(input())
count = [0]*(N+1)
for i in range(1, N+1):
    for j in range(i, N+1, i):
        count[j] += 1
ans = 0
for i in range(N+1):
    ans += i*count[i]
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

ans = 0
for i in range(1, x+1):
    k = x // i
    ans += i * k * (k+1) // 2

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for i in range(1, N+1):
    n = N//i
    ans += i*n*(n+1)//2
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
l = N//2
for i in range(1, l+1): #約数についてのループ
    n = N//i
    ans += i*n*(n+1)//2
    
# 約数がl+1より大きい時は、それを約数に持つ数は1個しかない(それ自身)
ans += (l+1+N)*(N-l)//2

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

total = 0
for n in range(1, N+1):
    total += N//n * (n + N - N%n)//2

print(total)

Submission status: Accepted

Solution code:
N = int(input())
count = [0]*(N+1)
for i in range(1, N+1):
    for j in range(i, N+1, i):
        count[j] += 1
ans = 0
for i in range(1, N+1):
    ans += i*count[i]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

times_ls = [0] * (n+1)
for base in range(1,n+1):
    for j in range(1,n+1):
        if base * j <= n:
            times_ls[base * j] += 1
        else:
            break
ans = 0
for i in range(1,n+1):
    ans += i * times_ls[i]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
cnt_tb = [0]*(n+1)
for i in range(1, n + 1):
    j = 1
    tmp = i*j
    while (tmp < n+1):
        cnt_tb[tmp] += 1
        j += 1
        tmp = i*j
ans = 0
for i in range(1, len(cnt_tb)):
    ans += i * cnt_tb[i]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for i in range(1, n+1):
  if i*2 > n:
    # 一気に足し上げて抜ける
    ans += (i + n) * (n - i + 1) // 2
    break

  # n 以下の最大の i の倍数
  last_term = n // i * i
  num_term = (last_term - i) // i + 1
  ans += (i + last_term) * num_term // 2
   

print(ans)

Submission status: Accepted

Solution code:

N = int(input())

ans = 0
for n in range(1, N + 1):
    m = N // n
    ans += m * (m + 1) // 2 * n
print(ans)

Submission status: Accepted

Solution code:

N = int(input())

ctr = [1] * (N + 1)
for n in range(2, N + 1):
    for v in range(n, N + 1, n):
        ctr[v] += 1

ans = 0
for n in range(1, N + 1):
    ans += n * ctr[n]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for x in range(1, N + 1):
    n = N // x
    #ans += n * (2 * x + (n - 1) * x) // 2
    ans += n * ( x + n * x) // 2

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = sum([(N//i) * (N//i + 1) * i / 2  for i in range(1, N+1)])
print(int(ans))

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
 
for i in range(1, N+1):
  Y = N // i
  ans += Y * (Y+1) * i / 2
  
print(int(ans))

Submission status: Accepted

Solution code:
import math
import math
N = int(input())
N_MAX = 10 ** 7
table = [1]*N

def get_divisors(n):
  num = 0
  ceil = n
  if n == 1:
    return 1
  for i in range(1, n+1):
    q, mod = divmod(n, i)
    if mod == 0: 
      num += 2
      ceil = q
    if i < ceil: break
  print(n, num)
  return num

ans = 0
for i in range(2,N+1):
  for j in range(1,math.floor(N/i)+1):
    table[i*j-1] += 1

for i, div in enumerate(table):
  ans += (i+1)*div
print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(input())

res = 0
for k in range(1, N+1):
    y = N // k
    res += k * y * (y+1) // 2

print(res)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1, n+1):
    m = n//i
    ans += (2*i*m + (m-1)*i*m) // 2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1, n+1):
  d = n // i
  ans += d*(d+1)//2*i
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(1,n+1):
  k=n//i
  ans+=i*(k*(k+1)//2)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
now=0
for i in range(1,n+1):
    now+=(i+(i*(n//i)))*(n//i)//2
print(now)

Submission status: Accepted

Solution code:
n = int(input())

def g(x):
    return x*(x+1)//2

ans = 0
for k in range(1,n+1):
    ans += k*g(n//k)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1, N+1):
  k = N//i
  ans += i * k * (k+1) // 2
print(ans)

Submission status: Accepted

Solution code:

n = int(input())

ans = 0

for i in range(1,n+1):
    k = n//i
    ans += k*(k+1)*i//2
    
print(ans)

Submission status: Accepted

Solution code:
def make_prime_table(n):
    sieve = list(range(n + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(4, n + 1, 2):
        sieve[i] = 2
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i] != i:
            continue
        for j in range(i * i, n + 1, i * 2):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


def f(X):
    t = []
    a = X
    while a != 1:
        if len(t) != 0 and t[-1][0] == prime_table[a]:
            t[-1][1] += 1
        else:
            t.append([prime_table[a], 1])
        a //= prime_table[a]
    result = 1
    for _, n in t:
        result *= n + 1
    return result


N = int(input())

prime_table = make_prime_table(N)
result = 0
for K in range(1, N + 1):
    result += K * f(K)
print(result)

Submission status: Accepted

Solution code:
N=int(input())
S=0
for i in range(1,N+1):
    S=S+i*(N//i)*(N//i+1)//2
print(S)

Submission status: Accepted

Solution code:
# import time
N = int(input())
ssum = 0
# start = time.time()
for k in range(1, N + 1):
    X = int(N / k)
    ssum += k * X * (X + 1) / 2
print(int(ssum))
# elapsed_time = time.time() - start
# print("elapsed_time:{0}".format(elapsed_time) + "[sec]")

Submission status: Accepted

Solution code:
N = int(input())

ans=0
for i in range(1,N+1):
	n=N//i
	ans+=i*(n+1)*n/2

print(int(ans))

# 2darray [[0] * 4 for i in range(3)]
# import itertools

Submission status: Accepted

Solution code:
N = int(input())

def gauss_count(n):
    return n*(n+1)//2

print(sum(x * gauss_count(N//x) for x in range(1, N+1)))

Submission status: Accepted

Solution code:
import math

N = int(input())
s = 0

# def devisor(x):
#     count = 0
#     for i in range(1,math.floor(math.sqrt(x))+1):
#         if (x % i) == 0:
#             count += 2
#             if i**2 == x:
#                 count -= 1
#     return count

# for i in range(1, N+1):
#     s += i * devisor(i)

for i in range(1,N+1):
    y = math.floor(N/i)
    s += y*(y+1)*i//2

print(s)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for i in range(1,N+1):
  j = N//i
  ans += (j+1)*i*j//2

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for i in range(1, n+1):
    g = n // i
    ans += i * (g*(g+1))//2

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1, N+1):
  n = N // i
  ans += n * ((n+1)*i) // 2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

def cnt(n):
  c = 0
  for i in range(1, N+1):
    n = N // i
    j  = i * n
    c += (i + j) * n // 2
  return c

print(cnt(N))

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1,N+1):
    k = N//i
    ans += k*(k+1)*i//2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

total = 0
for j in range(1, n + 1):
  max_num = n // j
  total += (1 + max_num) * max_num * j // 2
print(total)

Submission status: Accepted

Solution code:
a=int(input())
b=(a)//2+1
ans=0
for i in range(1,b,1):
  x=a//i
  ans+=((x**2+x)//2)*i
ans+=(a**2+a+b-b**2)//2
print(ans)

Submission status: Accepted

Solution code:
def g(x):
  return x*(x+1)//2
n=int(input())
ans=0
for i in range(1,n+1):
  ans=ans+i*g(n//i)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for x in range(1, N+1):
    ans += (x+N//x*x)*(N//x)//2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

sum = 0

for j in range(1,N+1):
    k = N//j
    sum += (1+k)*k*j//2
print(sum)

Submission status: Accepted

Solution code:
N = int(input())
res = 0
#a = [0]*(N+1)
#for i in range(1,N+1):
#    for j in range(i,N+1,i):
#        a[j] += 1
#for i in range(1,N+1):
#    res += i * a[i]
for i in range(1,N+1):
    p = N // i
    res += i * p*(p+1)//2

print(res)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1, N + 1):
    b = N // i
    ans += i * b * (b + 1) // 2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
SUM = 0
for i in range(1, N+1):
    SUM += (i*(N//i)*((N//i)+1))//2
print(SUM)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

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

    res = 0
    for i in range(1, n + 1):
        res += i * prime_cnt[i]
    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
from numba import jit
@jit
def Sum_divisors():
    n,ans=int(input()),0
    for i in range(1, n+1):
        for j in range(i, n+1, i):ans+=j
    print(ans)

Sum_divisors()

Submission status: Accepted

Solution code:
N = int(input())
divisions = [0] * (10 ** 7 + 1)
for i in range(1, N + 1):
    for j in range(i, N + 1, i):
        divisions[j] += 1
ans = 0
for i in range(1, N + 1):
    ans += i * divisions[i]
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque
from operator import mul
from functools import reduce

n = int(input())

m = 0
for i in range(1,n+1):
    a = n // i
    m += a*(a+1)*i//2

print(m)

Submission status: Accepted

Solution code:
from numba import jit

@jit
def resolve():
    N = int(input())

    ans = 0
    for n in range(1, N+1):
        for m in range(n, N+1, n):
            ans += m
    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())

    ans = 0
    for i in range(1, N+1):
        n = N // i
        ans += i * (n + 1) * n // 2
    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
ans = 0
for i in range(1,N+1):
    n = N//i
    ans += i * n*(n+1)//2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
A = [0] * (n + 1)
for i in range(1, n + 1):
  for j in range(i, n + 1, i):
    A[j] += 1
print(sum(i * A[i] for i in range(1, n + 1)))

Submission status: Accepted

Solution code:

n=int(input())
g=0
for i in range(1,n+1):
    g+= 0.5*i*(n//i)*((n//i)+1)
print(int(g))

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for m in range(1, int(n**.5) + 1):
    ans += m * (m + (n // m)) * ((n // m) + 1 - m)
k = int(n**.5)
ans -= k * (k + 1) * (2 * k + 1) // 6

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
fn=[1]*(n+1)
for i in range(2,n+1):
  j=1
  while i*j<=n:
    fn[i*j]+=1
    j+=1
ans=0
for i in range(n+1):
  ans+=i*fn[i]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
k = [0] * (n+1)
for i in range(1, n+1):
    for j in range(i, n+1, i):
        k[j] += 1
for i in range(1, n+1):
    ans += i * k[i]
print(ans)

Submission status: Accepted

Solution code:
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    N = int(readline().rstrip())
    ans = 0
    for i in range(1, N+1):
        n = N // i
        ans += 0.5 * n * (2*i + i * (n-1))
    print(int(ans))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
lis = [0]*(n+1)
for i in range(2,n+1):
    j = 1
    while i*j <= n:
        lis[i*j] += 1
        j += 1
ans = 0
for i in range(2,n+1):
    ans += (lis[i]+1)*i
print(ans+1)

Submission status: Accepted

Solution code:
N = int(input())

K = [0] * (N+1)

for i in range(1, N+1):
    for j in range(i, N+1, i):
        K[j] += 1
ans = 0
for i in range(1, N+1):
    ans += i * K[i]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

for i in range(1, n + 1):
    t = n//i
    ans += 0.5 * i * t * ( t + 1)

print(int(ans))

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

for i in range(1, n + 1):
    if i == 1:
        ans += sum(range(1,n + 1))
    else:
        t = n//i
        ans += 0.5 * i * t * ( t + 1)

print(int(ans))

Submission status: Accepted

Solution code:
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main(N):
    div = np.zeros(N+1, np.int64)
    for n in range(1, N+1):
      for m in range(n, N+1, n):
        div[m] += m
    return div.sum()

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8, ))
    cc.compile()

from my_module import main

N = int(read())
print(main(N))

Submission status: Accepted

Solution code:
#D
n = int(input())
#約数の数を求める＞＞倍数であり、n以下であるものの総和を求める

ans = 0
for i in range(1, n + 1):
    #iの倍数の数を求める
    m = n // i
    #初項i:公差i:m項までの等比数列の和
    ans += m * (2 * i + i * (m - 1)) *0.5
print(int(ans))

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1, N+1):
    n = N // i
    ans += 0.5 * n * (2*i + i * (n-1))
print(int(ans))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.readline
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N = int(read())
ans = 0
for i in range(1, N+1):
    n = N // i
    ans += 0.5 * n * (2*i + i * (n-1))
print(int(ans))

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.readline

N = int(read())
ans = 0
for i in range(1, N+1):
    n = N // i
    ans += 0.5 * n * (2*i + i * (n-1))
print(int(ans))

Submission status: Accepted

Solution code:
N = int(input())
I = [0 for i in range(N)]
answer = 0
for i in range(1, N+1):
    answer += (i + (N//i) * i) * (N//i) //2
print(answer)

Submission status: Accepted

Solution code:
N = int(input())


def f(x):
    result = N // x
    return result

ans = 0
for x in range(1, N + 1):
    Y = f(x)
    ans += x * Y * (Y + 1) / 2
print(int(ans))

Submission status: Accepted

Solution code:
N = int(input())
ans = 0

for i in range(1, N + 1):
    ans += i * (N//i) * (N//i + 1)

ans /= 2

print(int(ans))

Submission status: Accepted

Solution code:
n = int(input())
ans = 0

for i in range(1,n+1):
	y = n//i
	g = i*(y*(y+1)//2)
	ans += g

print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ans = n * (n + 1) - 1  # 1とk 自信
 
    i = 2
    while i * i <= n:
        num = n // i
        min_i = i * i
        max_i = i * num
        ans += (num - i + 1) * (min_i + max_i)  # 自分自身
        ans -= min_i
        i += 1
    print(ans)
 
 
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
k = np.arange(1,n+1)
d = n // k
print((k*d*(d+1)//2).sum())

Submission status: Accepted

Solution code:
N = int(input())

def solve():
    ans = 0
    for k in range(1,N+1):
        d = N//k
        ans += k*d*(d+1)//2
    return ans

if __name__ == "__main__":
    print(solve())

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

for i in range(1, N+1):
    y = N//i
    ans += ((y*(y+1))//2)*i
print(ans)

Submission status: Accepted

Solution code:
# Sum of Divisors
import math

N = int(input())
ans = 0

for i in range(1,N+1):
    K = math.floor(N/i)
    ans += (K * (K+1) * i)/2

print(int(ans))

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1, N+1):
    Ni = N // i
    ans += i*Ni*(Ni+1) // 2

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1, n + 1):
    num = n // i
    ans += num * (i + i * num) / 2
print(int(ans))

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(1,n+1):
  j=n//i
  ans+=i*j*(j+1)//2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = (n + 1) * n // 2
for i in range(2, n + 1):
    j = 1
    while i * j <= n:
        ans += i * j
        j += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = (n + 1) * n // 2
for i in range(2, n + 1):
    for j in range(n):
        if i * j > n:
            break
        ans += i * j
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for j in range(1, N+1):
    l = N // j
    ans += j * l * (l+1) // 2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for j in range(1, n+1):
  b = n//j
  ans += b * (b+1) * j // 2
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for x in range(1,n+1):
  b=n//x
  c=x*b
  ans1=(x+c)*b//2
  ans+=ans1

print(ans)

Submission status: Accepted

Solution code:
def sumOfNaturalNumber(n):
  return n*(n+1)/2

N = int(input())

ans=0
for i in range(1,N + 1):
  n = N//i
  ans += sumOfNaturalNumber(n)*i
print(int(ans))

Submission status: Accepted

Solution code:
N = int(input())

dp = [0] * N

for i in range(1, N+1):
    for j in range(1, N // i + 1):
        dp[j*i-1] += 1
ans = 0
for i, d in enumerate(dp):
    ans += (i+1) * d

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(1,n+1):
    x=n//i
    ans+=(i+x*i)*x//2
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
li = [0]*(n+5)
for i in range(1,n+1):
    for j in range(i,n+1,i):
        li[j] += 1
ans = 0
for i in range(1,n+1):
    ans += i*li[i]
print(ans)