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
Answers
Answered by
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
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
Math,
1 month ago
Math,
1 month ago
Physics,
1 month ago
English,
3 months ago
English,
3 months ago
Social Sciences,
10 months ago
Computer Science,
10 months ago