MCPcopy Create free account
hub / github.com/arguiot/TheoremJS / primePi

Method primePi

__test__/theorem.js:1282–1296  ·  view source on GitHub ↗
(n)

Source from the content-addressed store, hash-verified

1280 return list
1281 }
1282 primePi(n) {
1283 n = new BigNumber(n).toNumber()
1284 if (n < 2) {
1285 throw "[TheoremJS] Number should be greater or equal to 2"
1286 }
1287 if (n > Number.MAX_SAFE_INTEGER) {
1288 throw `[TheoremJS] Input was larger than ${Number.MAX_SAFE_INTEGER}`
1289 }
1290 const gen = this.sieve()
1291 let out = 0
1292 for (var i = 0; i < n; i = gen.next().value) {
1293 out += 1
1294 }
1295 return new BigNumber(out - 1)
1296 }
1297 round(n, precision = 0) {
1298 const tenPow = this.pow(10, precision)
1299 return new BigNumber(n).times(tenPow).integerValue(BigNumber.ROUND_HALF_CEIL).div(tenPow)

Callers

nothing calls this directly

Calls 1

sieveMethod · 0.95

Tested by

no test coverage detected