Skip to content

Instantly share code, notes, and snippets.

@yohhoy
Last active July 5, 2022 10:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yohhoy/45743ae6572855e3bb30aa39879c53e9 to your computer and use it in GitHub Desktop.
Save yohhoy/45743ae6572855e3bb30aa39879c53e9 to your computer and use it in GitHub Desktop.
Fibonacci with VLA on C99
#include <stdio.h>
size_t f(size_t, char [][*]);
size_t f(size_t n, char r[][2 < n ? f(n-2, 0) + f(n-1, 0) : 1])
{
return sizeof(*r);
}
int main()
{
printf("%zu\n", f(10, 0)); // 55
}
@yohhoy
Copy link
Author

yohhoy commented Dec 2, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment