设计算法求解π/4的近似解

问题描述:

设计算法求解π/4的近似解

DIM sign AS INTEGER
DIM dem AS DOUBLE
DIM frac AS DOUBLE
DIM piDividedByFour AS DOUBLE
frac = 1#
piDividedByFour = 0#
dem = 1#
sign = 1#
DO
piDividedByFour = piDividedByFour + frac
dem = dem + 2#
sign = 0 - sign
frac = sign / dem
LOOP UNTIL ABS(frac) PRINT "π/4="; piDividedByFour
END