sum of prime numbers python program?

Write a function sum_primes(N) that adds all the prime numbers (that is: integers that are only divisible by 1 and themselves) between 1 and argument N and returns the result. Write a program that asks the user to enter a number Q and prints onto the console the sum of all prime numbers up to Q, using the sum_primes() function.

can someone answer this for me please

2 Answers

Relevance
  • 1 month ago

    Hi, Adriana. Have you had a go at coding this? I suggest you simplify: start by writing a program that determines whether or not a number is prime. That would be a good building block to start with. Can you do that?

    • ...Show all comments
    • brilliant_moves
      Lv 7
      1 month agoReport

      In your code, I think it should be
      for i in range (1, n):
        if i > 1:
      Forget about num. Use i instead. Delete "num = n[i]" - this makes no sense ay all!
      Good luck!

    • Login to reply the answers
  • 1 month ago

    This is WAY too long to answer on Yahoo Answers.  Anyways, what computer language or software do you want to use?

Still have questions? Get your answers by asking now.