server monitoring
+ Reply to Thread
Results 1 to 2 of 2

Thread: [PHP] Solving Euler Project #2

  1. #1
    Join Date
    Sep 2006
    Posts
    1,649

    [PHP] Solving Euler Project #2

    For more info visit this thread - [url]http://www.all-nettools.com/forum/showthread.php?t=76**[/url]

    The Problem - "Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million."

    The Solution
    [PHP]<?php

    /*********************************
    * The Euler Project #2 Solution *
    * Coded By Moonbat *
    * July **, 2008 *
    *********************************/
    $first = 0; // Here are the two numbers that...
    $second = *; // ...we have to start with
    $wing = array(); // Keeping ***** of the even-numbered Fibonacci numbers
    for ($i=0; $i<=**; $i++) {
    $fibonacci = $first + $second; // 0+*, *+*, *+2, 2+*
    $first = $second; // 0-->*, *-->*, *-->2, 2-->*
    $second = $fibonacci; // *-->2, 2-->*, *-->5, 5-->8
    echo "$fibonacci <br>";
    if (($fibonacci &#*7; 2) == 0) { // If the current Fibonacci number is even
    $wing[$i] = $fibonacci;
    } else {
    echo "";
    }
    }
    $arraysum = array_sum($wing); // Add 'em all up!
    echo "<hr>" . $arraysum;

    ?>[/PHP]
    Last edited by Moonbat; 07-13-2008 at 07:05 PM.
    "Workers of the world unite; you have nothing to lose but your chains." -Karl Marx

  2. #2
    Join Date
    Sep 2006
    Posts
    1,649
    After doing a lot of other stuff (using programming and my knowledge of F****occi numbers alone) I got to the final stopping point of **. Since this was my final solution (lolololol insart hitler joke hear) I wanted to make it not have to do more than was needed. I guess I should've done what you did and kept ***** of the current F****occi number to make sure it wasn't over 4,000,000.
    "Workers of the world unite; you have nothing to lose but your chains." -Karl Marx

+ Reply to Thread

Similar Threads

  1. Euler #6
    By Moonbat in forum Programming
    Replies: 1
    Last Post: 07-26-2008, 10:07 AM
  2. PHP - Euler #5 Problems :(
    By Moonbat in forum Programming
    Replies: 3
    Last Post: 07-18-2008, 01:06 PM
  3. [PHP] Solving Euler Project #*
    By Moonbat in forum Programming
    Replies: 1
    Last Post: 07-13-2008, 04:38 PM
  4. Solving Quadratics with PHP
    By Moonbat in forum Programming
    Replies: 1
    Last Post: 07-12-2008, 01:27 PM
  5. PHP Project Help Needed
    By Moonbat in forum Programming
    Replies: 8
    Last Post: 03-29-2008, 09:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts