RosettaCodeData/Task/Arithmetic-geometric-mean/DuckDB/arithmetic-geometric-mean-1.duckdb
2025-08-11 18:05:26 -07:00

12 lines
257 B
Text

with recursive
rec(rn, a, g, diff) as (
select 1, 1.0, 1/sqrt(2), 1 - 1/sqrt(2)
union all
select rn + 1, (a + g)/2, sqrt(a * g), (a + g)/2 - sqrt(a * g)
from rec
where diff > 1e-15
)
select *
from rec
where diff <= 1e-15
;