Given a positive integer N., The task is to find the value of      where function F(i) for the number i be defined as the sum of all divisors of ‘i‘.
Example 1:
Input:
N = 4
Output:
15
Explanation:
F(1) = 1
F(2) = 1 + 2 = 3
F(3) = 1 + 3 = 4
F(4) = 1 + 2 + 4 = 7
ans = F(1) + F(2) + F(3) + F(4)
    = 1 + 3 + 4 + 7
    = 15
Example 2:
Input:
N = 5
Output:
21
Explanation:
F(1) = 1
F(2) = 1 + 2 = 3
F(3) = 1 + 3 = 4
F(4) = 1 + 2 + 4 = 7
F(5) = 1 + 5 = 6
ans = F(1) + F(2) + F(3) + F(4) + F(5)
    = 1 + 3 + 4 + 7 + 6
    = 21
Your Task:  
You don't need to read input or print anything. Your task is to complete the function sumOfDivisors() which takes an integer N as an input parameter and returns the answer of the problem asked.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints:
1 <= N <= 10^{6}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3





class Solution:

    def sumOfDivisors(self, N):

    	#code here 

Solutions:
class Solution:

	def sumOfDivisors(self, N):
		s = 0
		for i in range(1, N + 1):
			s = s + N // i * i
		return s


class Solution:

	def sumOfDivisors(self, N):
		count = 0
		for num in range(1, N + 1):
			count += N // num * num
		return count


class Solution:

	def sumOfDivisors(self, N):
		res = 0
		import math
		for i in range(1, N + 1):
			res += N // i * i
		return res


class Solution:

	def sumOfDivisors(self, n):
		c = 0
		for i in range(1, n + 1):
			c += n // i * i
		return c


import sys
sys.setrecursionlimit(10 ** 6)

class Solution:

	def sumOfDivisors(self, N):
		sum = 0
		for i in range(1, N + 1):
			sum += N // i * i
		return sum


import math as m

class Solution:

	def sumOfDivisors(self, N):
		tsum = 0
		for i in range(1, N + 1):
			tsum += i * (N // i)
		return tsum


class Solution:

	def sumOfDivisors(self, N):
		sumX = 0
		for i in range(1, N + 1):
			sumX += N // i * i
		return sumX

	def fun(self, j):
		sumY = 0
		return sumY


class Solution:

	def sumOfDivisors(self, N):
		sum = 0
		for i in range(1, N + 1):
			sum += N // i * i
		return int(sum)


class Solution:

	def sumOfDivisors(self, N):
		sum_ = 0
		for index in range(1, N + 1):
			sum_ += index * (N // index)
		return sum_


class Solution:

	def sumOfDivisors(self, N):
		ans = 0
		for a in range(1, N // 2 + 1):
			ans += a * (N // a)
		ans += N * (N + 1) // 2 - N // 2 * (N // 2 + 1) // 2
		return ans


class Solution:

	def sumOfDivisors(self, N):
		sum = 0
		for a in range(1, N + 1):
			sum += a * (N // a)
		return sum


from math import sqrt

class Solution:

	def sumOfDivisors(self, n):
		res = 0
		for i in range(1, n + 1):
			res += N // i * i
		return res


import math

class Solution:
	d = {}

	def sumOfDivisors(self, N):
		s = 0
		for i in range(1, N + 1):
			s += N // i * i
		return s


class Solution:

	def f(n: int) -> int:
		(res, r) = (0, 1)
		while r * r <= n:
			if n % r == 0:
				res += r
				if r != n // r:
					res += n // r
			r += 1
		return res

	def sumOfDivisors(self, N):
		ans = 0
		for i in range(1, N + 1):
			ans += i * (N // i)
		return ans


class Solution:

	def sumOfDivisors(self, n):
		s = 0
		for i in range(1, n + 1):
			div = n // i
			s += div * i
		return s


import math

class Solution:

	def sumOfDivisors(self, N):
		sum = 0
		i = 1
		while i <= N:
			sum += i * (N // i)
			i += 1
		return sum


class Solution:

	def sumOfDivisors(self, N):
		Sum = 0
		i = 1
		while i <= N:
			Sum += i * (N // i)
			i += 1
		return Sum


class Solution:

	def sumOfDivisors(self, N):
		res = 0
		for x in range(1, N + 1):
			res += N // x * x
		return res