Last active
November 7, 2018 16:15
-
-
Save nikhedonia/dc0018d92d765043cab556e318aed466 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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