fork(3) download
  1. #include <iostream>
  2.  
  3.  
  4. double compute_pi( const int PRECISION )
  5. {
  6. double pi = 4.0;
  7. for( int i = 0; i < PRECISION; ++i )
  8. {
  9. pi += (i % 2 == 0 ? -4.0 : 4.0) / ( 3.0 + i * 2 );
  10. }
  11. return( pi );
  12. }
  13.  
  14. int main() {
  15. std::cout << compute_pi( 1e6 ) << std::endl;
  16. return 0;
  17. }
Success #stdin #stdout 0.01s 3340KB
stdin
Standard input is empty
stdout
3.14159