A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

so iv just started the prime number challenge, please help, basically, im having trouble giving python a command, her is a simple version of the line while x%y == >0: this gives me syntax error, im trying to say that, if x/y leaves a remainder, then x=x-1, if not, a+1 and repeat where a is the number being tested.... if that makes any sense? lol

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Hi if you want know the simplest way to solve the prime number .. here is the way. you dont need to check the whole number ,,,just start the for loop from two till you arrive to the half of the number that you are attempting to know if it is prime or not. here is the example of what i say ... for(int i=2;x/2;i++) if(x%i==0) it is not prime ; else it is prime.

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    you just need if x % y > 0 not ==

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    pmpn8ez is right, but didn't explain what is wrong with your statement. == and > are both comparison operations, so you're getting an error. Section 5.3 of the Python documentation can expand on this if you're interested. http://docs.python.org/library/stdtypes.html Hope this helps!

  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    hey, thanks to you both, i sorted it and you were both a big help, if you wouldn't mind taking a look at my new thread about 1b? would reallt be of help, thanks

  5. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.