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 1110601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:25:16+00:00 2026-05-17T02:25:16+00:00

Each new term in the Fibonacci sequence is generated by adding the previous two

  • 0

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, …
I made the program but my answer doesnt match.

#include<stdio.h>
int main()
{
 long unsigned int i,sum=0,x=1,y=2,num;
 for(i=0;i<4000000;i++)
 {
  num=x+y;
  if(i%2==0)
   sum+=num;
  x=y;
  y=num;
 }
 printf("%lu\n",sum);
 getchar();
 return 0;
}
  • 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-17T02:25:16+00:00Added an answer on May 17, 2026 at 2:25 am

    Three problems I can see:

    • You should start with x = 1, y = 1, since otherwise you skip the first even-valued Fibonacci;
    • Your loop condition should be (x + y) <= 4000000
    • You should test num for even-ness, not i.

    (After these changes, it should be obvious that you can omit i entirely, and therefore replace the for loop with a while loop)

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

Sidebar

Related Questions

I'm working on Project Euler problem #2 : Each new term in the Fibonacci
In C++, I've written a mathematical program (for diffusion limited aggregation) where each new
I am using System.Timers in my program. As we know each interval new thread
Can somebody tell me why this should be wrong? #Each new term in the
I'm working with a large set of hierarchical taxonomic terms, where each term (203)
What I'd like is to create a new unordered list for each new value
I'm trying to retrieve only word from inside each new instance of the newEntry
the following code (from a database object created for each new view): -(void)update:(NSString *)queryText{
I am trying to make a blackjack game where before each new round, the
I parse an xml file containing books, for each new node I go: Book

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.