Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5994261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:47:35+00:00 2026-05-22T23:47:35+00:00

The question goes like this: Each new term in the Fibonacci sequence is generated

  • 0

The question goes like this:

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By >starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …

By considering the terms in the Fibonacci sequence whose values do not exceed four million, >find the sum of the even-valued terms.

And this is what I wrote in PHP

<?php
function fibo($first, $second, $limit){
  $next = $first + $second;
  if ($next % 2 ==0) {
    $array[]= "$next";
  }

  do 
  { 
    fibo($second,$next, $limit);
  } while ($next < $limit);

  $sum=array_sum($array[]);
  echo "$sum";
}
fibo(1,2,4000000);
?>

My code doesn’t run though…can anyone help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:47:36+00:00Added an answer on May 22, 2026 at 11:47 pm

    Try changing $sum=array_sum($array[]); to $sum=array_sum($array); and see what it happens…

    Also, when you have a problem, it’s good to let the others know what kind of problem it is. Like the error message or something like that…

    If by any chance there are no errors reported, try to turn them on.

    EDIT:
    I remember that when solving some Euler problems recursively I happened to have a problem where the page crashed. This may happen due to some recursion limitations. I believe it’s similar to your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may seem like a stupid question, so here goes: Other than parsing the
Question goes like this.. Input n [the number of multiplications <= 1000] l1 l2
Ok, this may be a dumb question but here goes. I noticed something the
OK. This might be more of a math question but here goes. I have
this is my first question to stackoverflow so here it goes... I use cruise
This question might be kind of elementary, but here goes: I have a SQL
I don't know if this is strictly a programming question but here goes. I
This is maybe a stupid question, but since I am relatively new to UDP
Last night I asked a question like this, I'm not sure what's happening and
Similar questions have been asked, but nothing exactly like mine, so here goes. We

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.