Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- static void fib(std::vector<unsigned int> &v) {
- unsigned int x = 1, y = 2;
- do {
- if (!(x & 1))
- v.push_back(x);
- y = x + y;
- x = y - x;
- } while (x < 4000000);
- }
- int main() {
- unsigned int anitta = 0;
- std::vector<unsigned int> v;
- fib(v);
- for (unsigned short i = 0; i < v.size(); ++i)
- anitta += v.at(i);
- std::cout << anitta << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement