Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

sum of fibonacci series in c

// Sum of fibonacci series
#include <stdio.h>

int main()
{
    int fib[1000];
    int num, sum = 1, i;
    scanf(" %d", &num);

    fib[0] = 0;
    fib[1] = 1;
    printf(" %d + %d", fib[0], fib[1]);
    for(i = 2; i < num; i++){
        fib[i] = fib[i-1] + fib[i-2];
        printf(" + %d", fib[i]);
        sum += fib[i];
    }
    printf("
 = %d", sum);
    return 0;
}

 
PREVIOUS NEXT
Tagged: #sum #fibonacci #series
ADD COMMENT
Topic
Name
9+3 =