By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
with recursive
params as (select 4 n, 2 k),
r1 as (
select n, n res from params
union all select n - 1, res * (n - 1) from r1 where n > 1
),
r2 as (
select k, k res from params
union all select k - 1, res * (k - 1) from r2 where k > 1
),
r3 as (
select (n - k) m, (n - k) res from params
union all select m - 1, res * (m - 1) from r3 where m > 1
)
select max(r1.res) / max(r2.res) / max(r3.res)
from r1
cross join r2
cross join r3
max(r1.res) / max(r2.res) / max(r3.res) |
---|
6.00000000 |