[Tutor] Optimisation of prime number program (cont. from finding prime numbers)

Boykie Mackay boykie.mackay at gmail.com
Fri Sep 21 10:41:27 CEST 2007


Ok,I have learnt how to generate prime numbers and how to 'split'
input.The above was to help me solve the second 'SPOJ'
challenge,PRIME1.The challenge can be found at
<https://www.spoj.pl/problems/classical/sort=0,start=0> 

I have written my solution and tested it and it works fine,but
unfortunately it is times out when tested by 'SPOJ'.I don't know whether
it times out because it is inherently slow or because a certain
condition takes it into endless loops.I think it is simply because it
needs further optimisation.I have researched as much as I could but
can't find any way to improve the speed of the program (problem with
being a newbie is you don't know what you don't know!)

Could you please look at the program (attached) and advise possible
optimisations or point me to possible resources that would help solve
this challenge.

Thanks,

Boyks 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: prime1.py
Type: text/x-python
Size: 1453 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20070921/922bd058/attachment.py 


More information about the Tutor mailing list