Pure Programmer
Blue Matrix


Cluster Map

Project: Compute π Function

Write a function that computes and returns the value π which can be easily computed with standard math functions using one of the formula:

  • atan(1.0)*4.0
  • atan2(0.0, -1.0)
  • acos(-1.0)
  • 2.0*acos(0.0)

See [[Pi]]

Output
$ javac -Xlint ComputePi3.java $ java -ea ComputePi3 PI: 3.141592653589793 abs(PI - π): 0.0000000000e+00

Solution