Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 16 Online
OpenStudy (anonymous):

Hi, Can anyone please explain how to solve Ps1 ? I'm trying to solve it since 2 weeks :S Please help before I give up..

OpenStudy (anonymous):

hi , sorry what is the meaning of Psl?

OpenStudy (anonymous):

Are you watching the videos of this course ??

OpenStudy (anonymous):

no

OpenStudy (anonymous):

i study pure math and computer science but h donot hear about it

OpenStudy (anonymous):

ok, so you can start watching from here: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/video-lectures/ and you will understand everything,, this group is for studying this course only.

OpenStudy (anonymous):

ok ,thanks alot ahmed

OpenStudy (anonymous):

You're Welcome!

OpenStudy (anonymous):

Ahmed, I think Mioto's port should help you. It helped me a lot. THe link is... http://openstudy.com/study#/updates/4f3bd06ce4b0fc0c1a0f200e Or just look for Mioto...

OpenStudy (maitre_kaio):

can you tell what's the problem ? What part of the assignment don't you understand ?

OpenStudy (anonymous):

Yes, what do you not understand?

OpenStudy (anonymous):

Ok guys, I found that wanderboy solve the assignment, and here's his code: http://codepad.org/RhiGtGcn and It do the job, but when I simulate it by hand I didn't understand this condition: if divisor == num: in line 11, so can anyone help ?

OpenStudy (anonymous):

The idea is that if you go through the while loop up until the point where divisor (i.e., the number that you are using to test for primality) == number, you don't need to check anymore (there are other effective ways to code it, just using wanderboy example); If that happens, you are sure that it's a prime and you can increase count. Suppose you are testing 5, you try 5%2 != 0; 5%3 != 0; 5%4 != 0 but now divisor == num, i.e., it's a prime. If there was some unclear points in my explanation, just go ahead and ask :-)

OpenStudy (anonymous):

Thanks bmp, now I got it :)

OpenStudy (anonymous):

http://codepad.org/vodLXMGf look at this other way to do this easily, i made comments for you to be clear...

OpenStudy (anonymous):

actually your code is the second problem in the same assignment, not the first one, but thank you very much cause I was about to ask about this problem too, and you just did, Thanks Don :)

OpenStudy (anonymous):

mmm, well in my code are both first and 2nd problem! check it out you will notice it! (cuz in order to do the 2nd you have to do the first)

OpenStudy (anonymous):

You can see a bunch of solutions here: http://curiousreef.com/class/mit-opencourseware-600-introduction/lesson/2/retricen/1/

OpenStudy (anonymous):

Don, nice solution. So you can have lists operate on each other, and operation will be done every combination from the two lists, as seems you did in below? for listrange in range(2, 1000): for prime in range (2, listrange-1): #looking for prime numbers if listrange%prime == 0:

OpenStudy (anonymous):

ahmed i was also in trouble bro but i found a solution i will send it tomorrow a have not laptop and no internet at home now just wait .you know you can't give it up!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!