Skip to content

Instantly share code, notes, and snippets.

@Jacajack
Last active May 25, 2016 13:32
Show Gist options
  • Save Jacajack/a819b458cb39365cb4554a8eadaa20c9 to your computer and use it in GitHub Desktop.
Save Jacajack/a819b458cb39365cb4554a8eadaa20c9 to your computer and use it in GitHub Desktop.
Simple code that calculates and looks like Pi...
#include <stdio.h>
#include <inttypes.h>
int main(){uintmax_t step=0;
long double pi=4.0L;while(1)
{pi+= 4.0/ (
3.0L+ step *
2.0L) *( (
step% 2==0 )
?-1:1 );step
++;if (step%
(int) 1.00e6
==0 ) printf
("\r" "%.40Lf"
" - %e " "steps",pi,
(double) step ); } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment