2803. Factorial Generator ¶ TypeScript 1 2 3 4 5 6 7 8 9 10function* factorial(n: number): Generator<number> { if (n === 0) { yield 1; } let fact = 1; for (let i = 1; i <= n; ++i) { fact *= i; yield fact; } }