Lines 46
##### Permissions
Owner: Stou S.
Group Owner: SnortSnort
Viewable by Everyone
Editable by All Siafoo Users
Siafoo – the intersection of pastebin, help desk, version control, and social networking

# Euler Project Problem 2 0

 Language C++
# 's
` 1#include <iostream> 2 3/* 4 * Contrived operator overloaded solution 5 */ 6struct fib{ 7 8	int l, c, position; 910	fib() : l(1), c(1), position(0) {}1112	void operator++() {13		int tmp = c;14		c = l + c;15		l = tmp;16		++position;17	}1819	int get(){20		return c;21	}2223};2425/*26 * Recursive solution27 */28int fib_r(int p, int c, int limit){2930	if(p + c >= limit){31		return 0;32	}3334	if((p + c) % 2 == 0){35		return p + c + fib_r(c, p + c, limit);36	}else{37		return fib_r(c, p + c, limit);38	}39}4041int fib_i(){42	int sum = 0;4344	for(fib f; f.get() <= 4e6; ++f){45		if(f.get() % 2 == 0){46			sum += f.get();47		}48	}49	return sum;50}5152int main(){5354	// Run iterative solution55	std::cout<<fib_i()<<std::endl;5657	// Run recursive solution58	std::cout<<fib_r(1, 1, 4e6)<<std::endl;5960	return 0;61}`