Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8724451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:50:04+00:00 2026-06-13T07:50:04+00:00

Project Euler #10 I am using the following code: import math def is_prime(num): num_sqrt=int(math.sqrt(num))+1

  • 0

Project Euler #10

I am using the following code:

import math

def is_prime(num):
    num_sqrt=int(math.sqrt(num))+1
    for i in range(2, num_sqrt):
        if(num%i == 0):
            return False
    return True

prime_sum=3
counter=2

for a in range(5, 2000000, 2):
    if(is_prime(a)):
        counter = counter +1
        print a, counter
        prime_sum=prime_sum+a

print prime_sum

And I get as a result the 142913828920

The last 10 lines of the output of the above program are:

1999859 148925
1999867 148926
1999871 148927
1999889 148928
1999891 148929
1999957 148930
1999969 148931
1999979 148932
1999993 148933
142913828920

The website http://www.numberempire.com/primenumbers.php confirms that 1999993 is the 148933rd prime (-> http://www.numberempire.com/primenumbers.php?number=1999993&action=check).

What’s wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:50:05+00:00Added an answer on June 13, 2026 at 7:50 am

    You are initializing your variable prime_sum incorrectly. The first two primes are 2 and 3 so it should be 5 (not 3). In modern mathematics, 1 is not usually considered a prime.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I solved Project Euler #14 using the following code: import time start_time = time.time()
I am working on Project Euler problem 5 and am using the following: def
I am trying to solve Project Euler problem in Clojure using recursion. The following
This is from project Euler, problem 2. I wrote the following seemingly innocent code:
Despite being a Project Euler program, the following code doesn't actually concern it much.
So on Project Euler the Problem 4 states the following: A palindromic number reads
I'm using Project Euler to learn MIPS, specifically using Problem 6 to learn how
I'm using Xcode to do the Project Euler problems in C++. I wanted to
I'm doing Project Euler #22: Using names.txt (right click and 'Save Link/Target As...'), a
I was trying to solve Project Euler problem 10 using python, but my program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.