Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #define pi M_PI
- int main(void)
- {
- int n;
- double p,e;
- p=1;
- for (n=1;n<10000;n++)
- {
- p*=(2.*n/(2.*n-1))*(2.*n/(2.*n+1));
- // printf("%lf \n",p);
- }
- e=((pi/2)-p)/(pi/2);
- printf("\nValor real: %lf \n",pi/2);
- printf("Valor calculado pela fórmula de Wallis: %lf \n",p);
- printf("Erro relativo: %lf \n\n",e);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement