' This program calculates the value of PI using
' the BBP formula, which was discovered in 1995
' by Canadian mathematician Simon Plouffe.
'
CLS
DEFDBL A-Z
FOR N = 0 TO 10
A1 = 4 / (8 * N + 1)
A2 = 2 / (8 * N + 4)
A3 = 1 / (8 * N + 5)
A4 = 1 / (8 * N + 6)
X16 = (1 / 16) ^ N
RESULT = (A1 - A2 - A3 - A4) * X16
SUM = SUM + RESULT
PRINT " n ="; N, RESULT,
IF N = 10 THEN COLOR 10
PRINT SUM
NEXT N