4 ms·
In C#: static IEnumerable<int> Fibonacci() { int first = 0; int second = 1; yield return first; yield
by useerup 5y ago
In C#:
static IEnumerable<int> Fibonacci()
{
int first = 0;
int second = 1;
yield return first;
yield return second;
while (true)
{
(first, second) = (second, second + first);
yield return second;
}
}
- whoisthemachine 5y agoInteresting use of tuples I had never considered before, a lot of state is packed in that `(first, second)...` block! Pretty fun though.