Would greatly appreciate your comments on my problem set 1 solution: http://pastebin.com/567ix4FU
It's little complicated I just gone through it...but it's seriously good....check my solution..
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.
I see...Thanks .... :)
Join our real-time social learning platform and learn together with your friends!