trying to do a program that sums all the even numbers in the sequence but i think im doing it wrong
heres my code
#include <stdio.h>
int fib ( int n );
int main ( int argc, char *argv[ ] ) {
int i , sum = 0 ;
for(i = 1; i <= 6 ;++i) {
int v = fib(i) ;
if( (v % 2) == 0 ) {
sum = sum + i ;
}
}
printf("the sum is %d",sum) ;
return 0 ;
}
int fib(int n) {
if ( n == 1 || n == 2) return 1 ;
else
return fib(n - 1) + fib( n - 2 ) ;
}