/***********************************************************
pi2.c -- 円周率
***********************************************************/
/* 相加相乗平均による方法 */
#N88BASIC
Dim i As Long
Dim a, b, s, t, last
a = 1: b = 1 / Sqr(2.0): s = 1: t = 4
For i = 0 To 2
last = a: a = (a + b) / 2: b = Sqr(last * b)
s = s - (t * (a - last) * (a - last)): t = t * 2
Print (a + b) * (a + b) / s
Next