var t = 0.05; var year = 20; function fn(y){ if (y == 1) return 10000; return t * fn(y-1) } console.log(fn(20));