CPSC120
Fundamentals of Computer Science

In-class Activity 9

  1. Leibniz Formula Approximation of pi

    Create a Python function that returns an approximation of pi using the Leibniz formula given the number of terms to sum. The Leibniz formula is:

    pi/4 = 1/1 - 1/3 + 1/5 - 1/7 + 1/9 …

  2. Wallis Formula Approximation of pi

    Create a Python function that returns an approximation of pi using the Wallis Formula given the number of terms to sum. The Walls formula is:

    pi/2 = 2/1 × 2/3 × 4/3 × 4/5 × 6/5 × 6/7 × 8/7 …