Skip to content

Instantly share code, notes, and snippets.

@nikhedonia
Last active November 7, 2018 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikhedonia/dc0018d92d765043cab556e318aed466 to your computer and use it in GitHub Desktop.
Save nikhedonia/dc0018d92d765043cab556e318aed466 to your computer and use it in GitHub Desktop.
auto fibonacci = []() -> seq<unsigned long long> {
auto a = 0ll;
auto b = 1ll;
while (true) {
co_yield a;
tie(a, b) = tuple{a + b, a};
}
};
static long N = 50;
int main() {
auto n = N;
auto items = fibonacci()
>> drop(n - 10)
>> take(n);
unsigned long long result = 0;
for (auto x : items) {
result += x;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment