Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- double compute_pi(int N){
- double i=2,j=1;
- int cont=0;
- double mult = 1;
- while(cont<N){
- mult = mult * (i/j);
- if(cont%2==0) j = j + 2;
- else i = i + 2;
- cont++;
- }
- return mult*2;
- }
- int main(){
- int N;
- double pi;
- scanf("%d", &N);
- pi = compute_pi(N);
- printf("%.12lf", pi);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement