Sum of all the prime divisors of a number

N = 1000005
def isPrime(n):
	
	if n <= 1:
		return False
	if n <= 3:
		return True

	if n % 2 == 0 or n % 3 == 0:
		return False

	i = 5
	while i * i <= n:
		if (n % i == 0 or
			n % (i + 2) == 0):
			return False
		i = i + 6

	return True

# https://codewindow.in/
def SumOfPrimeDivisors(n):
	sum = 0
	for i in range(1, n + 1) :
		if n % i == 0 :
			if isPrime(i):
				sum += i
	
	return sum

n = int(input())
print(str(SumOfPrimeDivisors(n)))

Leave a Comment

Your email address will not be published. Required fields are marked *