Re: [Tutor] Generate Prime Numbers

2015-06-11 Thread Mirage Web Studio
On 2015-06-11 12:38 AM, Laura Creighton wrote: In a message of Wed, 10 Jun 2015 23:11:36 +0530, George writes: On 2015-05-31 5:04 AM, Alan Gauld wrote: On 30/05/15 19:14, George wrote: Excuse me please for replying late. I got lists to use the method and it is more efficient and faster. (

Re: [Tutor] Generate Prime Numbers

2015-06-11 Thread Laura Creighton
Alas, PyPy STM only works for 64 bit linux for now. You are catching the PyPy project at the edge of its 'bleeding edge research'. We think in 1 or 2 releases windows users should be able to get it too, and I will let you know when that happens. And no promises. These sorts of things have a habi

Re: [Tutor] Generate Prime Numbers

2015-06-10 Thread Alan Gauld
On 10/06/15 18:41, Mirage Web Studio wrote: But now another problem i seem to notice that only 1 core of my amd Athlon X2 4core processor is being used. I suppose if all the four cores are simultaneously used then the programme might run even faster. Is there a way. One of the problems with t

Re: [Tutor] Generate Prime Numbers

2015-06-10 Thread Laura Creighton
In a message of Wed, 10 Jun 2015 23:11:36 +0530, Mirage Web Studio writes: > > > >On 2015-05-31 5:04 AM, Alan Gauld wrote: >> On 30/05/15 19:14, George wrote: > >Excuse me please for replying late. > >I got lists to use the method and it is more efficient and faster. >(Takes about 10 secs to proce

Re: [Tutor] Generate Prime Numbers

2015-06-10 Thread Mirage Web Studio
On 2015-05-31 5:04 AM, Alan Gauld wrote: On 30/05/15 19:14, George wrote: Excuse me please for replying late. I got lists to use the method and it is more efficient and faster. (Takes about 10 secs to process first 50 mil numbers) But now another problem i seem to notice that only 1 core

Re: [Tutor] Generate Prime Numbers

2015-05-30 Thread Alan Gauld
On 30/05/15 19:14, Mirage Web Studio wrote: and have at first devised a solution using class-object, thinking it easier, but it proved to be slower than my basic algorithm which i submitted earlier, I'm not surprised. You seem to have a talent for finding complex solutions to fairly simple pr

Re: [Tutor] Generate Prime Numbers

2015-05-30 Thread Danny Yoo
I'll review the code a bit. > import time > > starttime=time.time() > > class Number: > def __init__(self,number,p=None,n=None): > self.no=number > self.marked=None > self.p=p > self.n=n It would be helpful to document what the types of 'p' and 'n' are here.

Re: [Tutor] Generate Prime Numbers

2015-05-30 Thread Mirage Web Studio
On 2015-05-29 11:18 PM, Alan Gauld wrote: On 29/05/15 16:28, George wrote: Below is a sample code i created. Can i better it any way? Of course. There is always improvements that can be made. But in your case there are quite a few! def IsDivisibleBy3(number):#string variable v=0

Re: [Tutor] Generate Prime Numbers

2015-05-30 Thread Alan Gauld
On 30/05/15 00:37, Cameron Simpson wrote: def IsDivisibleBy3(number):#string variable return not int(number) % 3 To illustrate that there isn't just One Right Way, I would code the above like this: def IsDivisibleBy3(number): #string variable return int(number) % 3 == 0 Alan's cod

Re: [Tutor] Generate Prime Numbers

2015-05-29 Thread Stefan Behnel
Mirage Web Studio schrieb am 29.05.2015 um 17:28: > Below is a sample code i created. > Can i better it any way? Absolutely. Prime number generation is a very well researched and fun to implement topic. Thus many people have done it before. See this for algorithmic improvements: https://pypi.pyt

Re: [Tutor] Generate Prime Numbers

2015-05-29 Thread Cameron Simpson
On 29May2015 18:48, alan.ga...@btinternet.com wrote: On 29/05/15 16:28, Mirage Web Studio wrote: def IsDivisibleBy3(number):#string variable v=0 for c in number: v=v+int(c) if v%3==0: return True else: return False def IsDivisibleBy3(number):#string var

Re: [Tutor] Generate Prime Numbers

2015-05-29 Thread Alan Gauld
On 29/05/15 16:28, Mirage Web Studio wrote: Below is a sample code i created. Can i better it any way? Of course. There is always improvements that can be made. But in your case there are quite a few! def IsDivisibleBy3(number):#string variable v=0 for c in number: v=v+in

[Tutor] Generate Prime Numbers

2015-05-29 Thread Mirage Web Studio
Hello, Below is a sample code i created. Can i better it any way? Thanks George --- import time start_time = time.time() def IsDivisibleBy3(number):#string variable v=0 for c in number: v=v+int(c) if v%3==0: