“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.
Did you finish #3? My program is running too and taking a long time. Anguish!
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();
return;
}
}
}
}
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
end
end
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.
Sorry to break it to you Captain:
“Congratulations, the answer you gave to problem 3 is correct”
It ran in about 10 seconds.
It ran in about half a second when I took the printlns out 🙂
“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.
The next few look quite easy so I am going to bed.
Mine took longer but it eventually ran. I am through #5
Congratulations, the answer you gave to problem 6 is correct.
Too bad I need to get some work done or I would continue the chase.
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)
Great. Thanks.
Your current rating is 6% genius, having solved 11 out of 199 problems.