Caculate Pi value and return

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Caculate Pi value and return

chukuanyu
For example, Pi(1) will return 3, Pi(2) will return 3.1,……, Pi(5) will return 3.1415
Here's my code and I don't know how to do next step
Pi=function(N){
  Pi_value=0
  for(i in 0:N-1){
    Pi_value=Pi_value+4*(-1)^N/(2*(N+1)+1)
}
  Pi_value
}

Thank You