Ragged Clown

It's just a shadow you're seeing that he's chasing…


Wasting Time

Project Euler. Wasting time with Maths.

My attempt at #3 is running now (which probably means it is wrong).

Tags: ,

12 responses to Wasting Time

CaptainGroggySwagger June 16, 2008

Mine is getting stuck for some reason. I can’t figure it out.

private void button3_Click(object sender, EventArgs e)
long number = 600851475143;
long candidate = 0;
long halfnumber = ((number – 2) / 3);

for (long i = halfnumber; i > 1; i–)
if (number % i == 0)
candidate = i;
bool passed = true;

for (long j = 2; j < candidate; j++)
if (candidate % j == 0)
passed = false;

if (passed)
label3.Text = candidate.ToString();

Kevin June 16, 2008

I think the problem is that 30 billion squared is a rather large number.

Mine didn’t finish after a couple of hours and I needed to stop it. I will try again tonight. FYI I was checking for prime first.

for i in 1..(number/2)
if is_prime i
@primes << i
puts i if number % i == 0

I bet one of those Google people or Sun people or IBM people could do this in no time! I bet the unemployed would be fastest of all.

Kevin June 16, 2008

Sorry to break it to you Captain:

“Congratulations, the answer you gave to problem 3 is correct”

It ran in about 10 seconds.

Kevin June 16, 2008

It ran in about half a second when I took the printlns out 🙂

Kevin June 16, 2008

“Congratulations, the answer you gave to problem 4 is correct.”

I am learning a lot reading the thread after each answer. The Ruby answer to #4 was especially nice (I did it in Java because I don’t have Ruby on my windows partition and am too lazy to reboot)

Shame those Ruby experts and people at Google and the Sun people and the IBM people and the unemployed people don’t like doing puzzles.

Kevin June 16, 2008

The next few look quite easy so I am going to bed.

Kevin June 17, 2008

Congratulations, the answer you gave to problem 6 is correct.

Kevin June 21, 2008

Your current rating is 4% genius, having solved 7 out of 199 problems.

Back to Linux & Ruby. (and suddenly jealous of the people who get to do ruby at work)

Rob June 24, 2008

Great. Thanks.

Your current rating is 6% genius, having solved 11 out of 199 problems.

Leave a Reply

Your email address will not be published.