Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

1 of 2

C++ (gcc), 143 bytes

Explanation: it uses the constructor of a class to do the Fibonacci increment operation, and then sets up a variable number of global instances of that class to be initialized before main. The catch being that all those variables have to be named differently, and there's a bit of preprocessor magic needed to get the __LINE__ macro combined into the variable names.

(And then, since I couldn't see any way to be able to do a #include before the line which had to be commented in all occurrences but one, it ended up being a bit expensive to manually define a close-enough printf prototype.)

int m,n=1;struct A{A(){m+=n;n=m-n;}};extern"C" int printf(...);int main(){printf("%d",m);}
#define Y(x) A a##x;
#define X(x) Y(x)
X(__LINE__)//

Try it online!

AltStyle によって変換されたページ (->オリジナル) /