Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main(){
- int n = 1000, i, a;
- double Pi = 0.0;
- /* case a */
- for (i=0;i<n;i++){
- Pi += (4.0/(8.0*i+1.0)-2/(8.0*i+4.0)-1.0/(8.0*i+5.0)-1.0/(8.0*i+6.0))/pow(16.0,i);
- }
- printf("Pi = %f", Pi);
- /*end of case a*/
- /* case b
- printf("Specify a number \'a\'.\n");
- scanf("%d", &a);
- for (i=0;i<a;i++){
- Pi += (4.0/(8.0*i+1.0)-2/(8.0*i+4.0)-1.0/(8.0*i+5.0)-1.0/(8.0*i+6.0))/pow(16.0,i);
- }
- printf("\nPi = %f", Pi);
- end of case b*/
- return 0;
- }
Add Comment
Please, Sign In to add comment