Skip to content

Instantly share code, notes, and snippets.

@derekmc
Last active March 14, 2025 18:21
Show Gist options
  • Save derekmc/60ff447efc977efdd8b7ec8dc4916685 to your computer and use it in GitHub Desktop.
Save derekmc/60ff447efc977efdd8b7ec8dc4916685 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <math.h>
double fib(int n){
double a = 1;
double b = 1;
while(--n > 0){
b += a;
a = b - a;
}
return b;
}
int main(int argc, char *argv[]){
printf("Hello, World!");
int n = 5;
double a = fib(n);
printf("fib(%d) = %lf", n, a);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment