Skip to content

Instantly share code, notes, and snippets.

@unlight
Created October 21, 2012 21:03
Show Gist options
  • Save unlight/3928507 to your computer and use it in GitHub Desktop.
Save unlight/3928507 to your computer and use it in GitHub Desktop.
Fibonacci numbers
#include <stdio.h>
#include <stdarg.h>
#include <conio.h>
#include <math.h>
#include <stdlib.h>
int main(int argc, char const *argv[])
{
printf("Fibonacci numbers\n");
int f, i, prev, beforePrev;
for (i = 1; i <= 20; i++) {
if (i <= 2) {
f = 1;
} else {
f = beforePrev + prev;
}
printf("%d\n", f);
beforePrev = prev;
prev = f;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment