/calculate-pi

Calculate Pi using the Leibniz formula.

Primary LanguageJavaMIT LicenseMIT

Calculate Pi using Leibniz's Formula

Author: nefari0uss

language java Open Source Love Build Status

Summary

This program will request the approximate number of calculations to run in calculating π. The final result will be displayed on the console. Does not use the Math class. Assumption is that the user inputs an int.

Uses the Gottfried Leibniz formula for calculation of π:

1 - 1/3 + 1/5 - 1/7 + 1/9 - ... = π/4

Source: Wikipedia - Leibniz formula for π

Instructions

  • Use the given make file.
  • Alternatively, compile: $ javac Pi.java
  • Run: $ java Pi

Asciicast

asciicast