Skip to content

Instantly share code, notes, and snippets.

@joshumax
Last active March 1, 2016 00:04
Show Gist options
  • Save joshumax/033844512ecfe8b04979 to your computer and use it in GitHub Desktop.
Save joshumax/033844512ecfe8b04979 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdint.h>
#define ITERATIONS 85
typedef struct {
uint64_t previous;
uint64_t current;
} numpair;
int
main(void)
{
numpair col_one = {.previous=12, .current=18};
numpair col_two = {.previous=5, .current=5};
int i;
uint64_t tmp_num;
for (i = 0; i < ITERATIONS; i++) {
tmp_num = col_one.current;
col_one.current = col_one.previous + col_one.current;
col_one.previous = tmp_num;
tmp_num = col_two.current;
col_two.current = col_two.previous + col_two.current;
col_two.previous = tmp_num;
}
printf("Pi ~= %f\n",
((double)col_one.current/(double)col_two.current));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment