Computer Science, asked by madan537262, 3 months ago

12. Write a program to calculate the value of Pi with the help of the following series:
Pi = (4/1) - (4/3) + (4/5) - (4/7) + (4/9) - (4/11) + (4/13) - (4/15) ...​


ajitkrg4: hii
ajitkrg4: what do you mean pi
brainlistpro: Pi = (4/1) - (4/3) + (4/5) - (4/7) + (4/9) - (4/11) + (4/13) - (4/15) ...​
ajitkrg4: pi means what
brainlistpro: π pi
ajitkrg4: I don't known please give at detail
brainlistpro: I consider the value of π ( pi ) is the value of (4/1) - (4/3) + (4/5) - (4/7) + (4/9) - (4/11) + (4/13) - (4/15) ...​
ajitkrg4: thsnk
ajitkrg4: it's ok
brainlistpro: okay bye

Answers

Answered by brainlistpro
3

Answer:

Javascript program :

Explanation:

var Pi = 0 ;

var s = 1 ;

var n = 4 ;

var d = 1 ;

function cal(){

if( s = 1 ){

Pi += n/d ;

document.write(Pi);

d += 2 ;

s = 2 ;

}

if( s = 2 ){

Pi -= n/d ;

document.write(Pi);

d += 2 ;

s = 1 ;

}

}

setInterval( 0 , cal );

Answered by anyag884
8

Answer:

class xyz

[

public void main ( int n)

[

int i, sum=0,s=-1

for ( i=1,i<=n, i+=2)

[

s=s*-1

sum=(sum+(4/i))*s

]

sopln("pi="+sum)

]

]

Similar questions