Euler Problems

kinuthiA muchanE muchanek at gmail.com
Fri Jul 11 11:38:11 BST 2008


Andrew,

My is not very fast, 42 sec. How are you generating the divisors? I
think that is the crux of the matter. First I tried generating the
divisors by looking for them up-to to half of the number, for example:
<code>
	num = 28
	i= 1
	while i < num/2:
	 < more statements here >
</code>

... but that ran forever. So, I modified to search for up-to  the square
root of the number, that is:

<code>
	num = 28
	i= 1
	while i < num ** 0.5:
	 < more statements here >
</code>

... and I was within the minute threshold. 

The formula for generating the nth triangle number is T = n(n+1)/2,
would you imagine that multiplying by 0.5 instead of dividing by 2
shaved of a good 20 seconds!! How fast is your code running?

Cheers!

Kinuthia...
	

On Thu, 2008-07-10 at 20:24 -0400, Andrew Mathenge wrote:
> I've been working on #12 and the performance is simply not acceptable.
> Has anyone been able to get this running as fast as some of the posts
> on the site claim?
> 
> Andrew.
> 
> On Tue, Jul 8, 2008 at 12:40 PM, kinuthiA muchanE <muchanek at gmail.com> wrote:
> > Andrew,
> > For #10, if you do not use a sieve to find the primes, it will run
> > forever!
> > There is one called the Sieve of Erastothenes. Check it out on
> > Wikipedia.
> >
> > Good luck :-)
> > Kinuthia...
> > On Tue, 2008-07-08 at 10:47 -0400, Andrew Mathenge wrote:
> >> I'm still trying them. I started at #1 after the one you proposed
> >> (#26) and I'm at #10 now. This one should be very simple but I don't
> >> know why it's taking so long to run.
> >>
> >> Andrew.
> >>
> >> On Tue, Jul 8, 2008 at 6:52 AM, kinuthiA muchanE <muchanek at gmail.com> wrote:
> >> > Habari,
> >> > Anybody still trying these problems, you are all so, so silent...
> >> >
> >> > Kinuthia...
> >> >
> >> >
> >
> >




More information about the Ubuntu-ke mailing list