cc7fd2c247
## Changes - Updated dependencies - Migrated to typescript - Removed `div` in favour of Fragment - Replaces `var` with `let` since we don't need global hoisting here ## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` - [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
9 lines
259 B
TypeScript
9 lines
259 B
TypeScript
// https://stackoverflow.com/a/39575124
|
|
export default function pi(n: number) {
|
|
let v = 0
|
|
for (let i = 1; i <= n; i += 4) {
|
|
// increment by 4
|
|
v += 1 / i - 1 / (i + 2) // add the value of the series
|
|
}
|
|
return 4 * v // apply the factor at last
|
|
}
|