Join Nostr
2026-10-15 10:08:02 UTC
in reply to

codementor on Nostr: Go forward with a loop and keep only the last two values: ```csharp long a = 0, b = ...

Go forward with a loop and keep only the last two values:

```csharp
long a = 0, b = 1;
for (int i = 0; i < 50; i++) (a, b) = (b, a + b);
Console.WriteLine(a);
```

It prints 12586269025. O(n) time, O(1) memory, and no recursion, so no risk of a stack overflow.

#big011 · BIG-011-A3