# Python program to find sum of primes 
# in range from 1 to n. 

# Returns sum of primes in range from 
# 1 to n 

def sumOfPrimes(n): 
	# list to store prime numbers 
	prime = [True] * (n + 1) 
	
	# Create a boolean array "prime[0..n]" 
	# and initialize all entries it as true. 
	# A value in prime[i] will finally be 
	# false if i is Not a prime, else true. 
	
	p = 2
	while p * p <= n: 
		# If prime[p] is not changed, then 
		# it is a prime 
		if prime[p] == True: 
			# Update all multiples of p 
			i = p * 2
			while i <= n: 
				prime[i] = False
				i += p 
		p += 1	
		
	# Return sum of primes generated through 
	# Sieve. 
	sum = 0
	for i in range (2, n + 1): 
		if(prime[i]): 
			sum += i 
	return sum

# Driver code 
n = 2000000
print(sumOfPrimes(n)) 

# This code is contributed by Sachin Bisht 
c3e9a09d4d73430ceb2e54c7fc2377c406885862
<mask token>

def sumOfPrimes(n):
    prime = [True] * (n + 1)
    p = 2
    while p * p <= n:
        if prime[p] == True:
            i = p * 2
            while i <= n:
                prime[i] = False
                i += p
        p += 1
    sum = 0
    for i in range(2, n + 1):
        if prime[i]:
            sum += i
    return sum


<mask token>

def sumOfPrimes(n):
    prime = [True] * (n + 1)
    p = 2
    while p * p <= n:
        if prime[p] == True:
            i = p * 2
            while i <= n:
                prime[i] = False
                i += p
        p += 1
    sum = 0
    for i in range(2, n + 1):
        if prime[i]:
            sum += i
    return sum


<mask token>
print(sumOfPrimes(n))

def sumOfPrimes(n):
    prime = [True] * (n + 1)
    p = 2
    while p * p <= n:
        if prime[p] == True:
            i = p * 2
            while i <= n:
                prime[i] = False
                i += p
        p += 1
    sum = 0
    for i in range(2, n + 1):
        if prime[i]:
            sum += i
    return sum


n = 2000000
print(sumOfPrimes(n))

# Python program to find sum of primes 
# in range from 1 to n. 

# Returns sum of primes in range from 
# 1 to n 

def sumOfPrimes(n): 
	# list to store prime numbers 
	prime = [True] * (n + 1) 
	
	# Create a boolean array "prime[0..n]" 
	# and initialize all entries it as true. 
	# A value in prime[i] will finally be 
	# false if i is Not a prime, else true. 
	
	p = 2
	while p * p <= n: 
		# If prime[p] is not changed, then 
		# it is a prime 
		if prime[p] == True: 
			# Update all multiples of p 
			i = p * 2
			while i <= n: 
				prime[i] = False
				i += p 
		p += 1	
		
	# Return sum of primes generated through 
	# Sieve. 
	sum = 0
	for i in range (2, n + 1): 
		if(prime[i]): 
			sum += i 
	return sum

# Driver code 
n = 2000000
print(sumOfPrimes(n)) 

# This code is contributed by Sachin Bisht 