use strict; use warnings; my $A1; my $A2; my $A3; my $A4; my $X16; my $SUM; my $PI = 0; print "\n\nThis program calculates the value of PI using the BBP formula, which was", "\ndiscovered in 1995 by Canadian mathematician Simon Plouffe.\n"; for (my $i = 0; $i < 18; $i++) { $A1 = 4 / (8 * $i + 1); $A2 = 2 / (8 * $i + 4); $A3 = 1 / (8 * $i + 5); $A4 = 1 / (8 * $i + 6); $X16 = (1 / 16) ** $i; $SUM = ($A1 - $A2 - $A3 - $A4) * $X16; $PI += $SUM; print "\n i = $i\t\t$SUM"; } print "\n\n\t PI = $PI\n";