Thread: Fibonacci sequence wont run.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    9

    Fibonacci sequence wont run.

    This is the second problem from Project Euler. here the detail:
    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 here is my code in C:
    Code:
    #include <stdio.h>
    int main()
    {
        int sum = 0, a = 1, b = 2, c=0;
        while(b<4000000)
            {
                c=a+b;
                if ( c%2==0 )
                {
                    continue;
                    if (c<4000000)
                    {
                        sum=sum+c;
                    }
                }
                a = b;
                b = c;
                
            }
        sum=sum+1;
        printf ("%d", sum);
        return 0;
    }
    Compiling run without error, however when i run the program(.exe file) from command prompt, it do nothing. I dont know what to do next, since there is no error statement to look at.

    Here the attachment if it help.
    Attached Files Attached Files
    • File Type: c 1.c (280 Bytes, 148 views)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fibonacci sequence
    By paut in forum C++ Programming
    Replies: 3
    Last Post: 11-13-2011, 12:27 PM
  2. Fibonacci Sequence
    By iGuardian in forum C++ Programming
    Replies: 19
    Last Post: 10-21-2011, 12:34 AM
  3. fibonacci sequence
    By cph in forum C Programming
    Replies: 57
    Last Post: 04-30-2009, 07:17 AM
  4. Fibonacci sequence
    By MuffanMan123 in forum C++ Programming
    Replies: 6
    Last Post: 02-26-2008, 09:15 AM
  5. Fibonacci sequence
    By girliegti in forum C++ Programming
    Replies: 8
    Last Post: 09-30-2003, 10:40 PM

Tags for this Thread