Wasting Time

Project Euler. Wasting time with Maths.

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

Published by

Ragged Clown

Based in San Jose, California

12 thoughts on “Wasting Time”

  1. 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;
    }
    }
    }
    }

  2. 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.

  3. “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.

  4. 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)

Leave a Reply

Your email address will not be published. Required fields are marked *