Turn the recursion upside down. Begin with the two known counts at the bottom, both 1, and climb: at each stair the fresh count is the sum of the pair in hand, and the older member of the pair is never needed again. The line prev, curr = curr, prev+curr reads both old values before it assigns either, so the shift needs no scratch variable. Ranging over an integer, as in for range n - 1, requires Go 1.22 or newer; the body runs n - 1 times, and not at all when that is zero or below, which is how 1 and 0 stairs fall through to return 1.