Last active
March 1, 2016 00:04
-
-
Save joshumax/033844512ecfe8b04979 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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