Project Euler #2: Even Fibonacci numbers

  • + 0 comments

    C++ implementation using this algorithm!

    long total = 0;
    long previous = 0;        
    long current = 2;        
    while(current < n) {  
    	total += current;          
    	long aux = current;
    	current = current * 4 + previous;
    	previous = aux;
    }
    cout << total << "\n";