The Programming Thread

Discussion in 'The Cheap Seats' started by Timpegoose, Jul 11, 2013.

  1. Timpegoose

    Timpegoose Walk On

    Joined:
    Jul 17, 2010
    Messages:
    7,157
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
     
    namespace EulerProject2
    {
        class Program
        {
            static void Main(string[] args)
            {
                int total = 0;
                int a = 0;
                int b = 1;
                int c = 0;
     
                do
                {
                    if (c % 2 == 0)
                        total += c;
                   
                    c = a + b;
                    a = b;
                    b = c;
                }
               
                while (c < 4000000);
     
                Console.WriteLine(total);
                Console.ReadLine();
            }
     
         
               
     
        }
    }
    
    Shaun Mason
    fuzzyl0gic

    Here's my shitty code to find the answer to "By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms."

    Also why I don't have comments in the current one I'm working on. When it's this short, I didn't bother.
     
  2. Shaun Mason

    Shaun Mason Somebody you used to know.

    Joined:
    Feb 9, 2009
    Messages:
    24,887
    Featured Threads:
    5

    Your style is rough, but good job.
     
  3. Timpegoose

    Timpegoose Walk On

    Joined:
    Jul 17, 2010
    Messages:
    7,157

    Very. Lol. I figure I can hack shit together until I understand some more advanced concepts then try and make it look pretty.
     
    • Like Like x 1
  4. fuzzyl0gic

    fuzzyl0gic No new friends

    Joined:
    Apr 14, 2010
    Messages:
    8,935

    Not bad! I'm assuming it works? :)
     
  5. Timpegoose

    Timpegoose Walk On

    Joined:
    Jul 17, 2010
    Messages:
    7,157

    Yeah, it popped out the correct answer at least. Probably not the most efficient, but it only takes like 5-7 seconds so not awful.
     

Share This Page