#include #include #include #include unsigned int fibonacci(unsigned int n) { if (n == 0) return 0; std::vector v(n, 1); adjacent_difference(v.begin(), v.end()-1, v.begin()+1, std::plus()); // "array" now contains the Fibonacci sequence from 1 up return v[n-1]; }