Skip to content

Instantly share code, notes, and snippets.

@dcampos
Created March 4, 2023 18:41
Show Gist options
  • Select an option

  • Save dcampos/da72832d4c414381e0463ab369c527e6 to your computer and use it in GitHub Desktop.

Select an option

Save dcampos/da72832d4c414381e0463ab369c527e6 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int fib(int n) {
switch (n) {
case 0:
return 0;
break;
case 1:
return 1;
break;
default:
return fib(n -1) + fib(n -2);
}
}
int main() {
for (int i = 0; i < 10; i++) {
printf("%d\n", fib(i));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment