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

Would greatly appreciate your comments on my problem set 1 solution: http://pastebin.com/567ix4FU

OpenStudy (anonymous):

It's little complicated I just gone through it...but it's seriously good....check my solution..

OpenStudy (vaboro):

Well, not bad, I think. Though, I suppose, it may lack some generalization and abstraction. Also, you use definition of prime in order to check if number n is prime. This process takes much time when n is relatively large. There is a faster method called a "trial division" method. I also used definition of prime for the check: def is_Prime_slow(n): '''the function returns n if n is prime and -1 if n is not prime''' k = n - 1 while k > 1: if n % k == 0: return -1 else: k = k - 1 return n But them I realized that it's very slow if I need to check a lot of number and if numbers get bigger and bigger, and I looked up definition of primes in wikipedia and found the "trial division" method that is relatively faster. Good work! Cheers.

OpenStudy (anonymous):

I see...Thanks .... :)

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!