Skip to content

Commit cc9d112

Browse files
committed
v1.1.0
1 parent 83dc92c commit cc9d112

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ primeupto is an math library for JavaScript and Node.js. It help you to find all
33

44
[![Version](https://img.shields.io/npm/v/primeupto)](https://www.npmjs.com/package/primeupto)
55
[![license](https://img.shields.io/npm/l/primeupto)](https://www.npmjs.com/package/primeupto)
6+
[![download](https://img.shields.io/npm/dw/primeupto)](https://www.npmjs.com/package/primeupto)
7+
[![download](https://img.shields.io/npm/dt/primeupto)](https://www.npmjs.com/package/primeupto)
68
[![Fork](https://img.shields.io/github/forks/letskhabar/primeupto?label=fork&style=social)](https://github.com/letskhabar/primeupto/fork)
79
[![Star](https://img.shields.io/github/stars/letskhabar/primeupto?style=social)](https://github.com/letskhabar/primeupto/stargazers)
810
[![watch](https://img.shields.io/github/watchers/letskhabar/primeupto?style=social)](https://github.com/letskhabar/primeupto/watchers)
911

1012

1113
## Features
1214

13-
- find prime number from 2 to n.
14-
- find prime number from m to n. // comming soon
15+
- find all prime number upto n.
16+
- find all prime number from m to n. // comming soon
17+
- find number of prime upto n.
18+
- find number of prime from m to n.
1519
- Can be used in command line as well.
1620
- Runs on any JavaScript engine.
1721
- Is easily extensible.
@@ -27,15 +31,25 @@ Install primeupto using [npm](https://www.npmjs.com/package/primeupto):
2731

2832

2933
```js
30-
const {primeupto} = require('primeupto');
34+
const {primeupto,primelength} = require('primeupto');
3135

3236
console.log(primeupto(5)); // 2,3,5
37+
console.log(primelength(5)); // 3
3338
console.log(primeupto(34)); // 2,3,5,7,11,13,17,19,23,29,31
39+
console.log(primelength(34)); // 11
3440
console.log(primeupto(25)); // 2,3,5,7,11,13,17,19,23
41+
console.log(primelength(25)); // 9
3542
console.log(primeupto(53)); // 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53
43+
console.log(primelength(53)); // 16
3644

3745
```
3846

47+
## Run
48+
49+
```
50+
npm test
51+
```
52+
3953
See the [Getting Started](https://github.com/letskhabar/primeupto) for a more detailed tutorial.
4054

4155

index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,22 @@ module.exports.primeupto = max =>
1313
}
1414
}
1515
return primes;
16+
};
17+
18+
module.exports.primelength = max =>
19+
{
20+
var store = [], i, j, primes = [];
21+
for (i = 2; i <= max; ++i)
22+
{
23+
if (!store [i])
24+
{
25+
primes.push(i);
26+
for (j = i << 1; j <= max; j += i)
27+
{
28+
store[j] = true;
29+
}
30+
}
31+
}
32+
return primes.length;
1633
}
34+

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
{
22
"name": "primeupto",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "primeupto",
55
"main": "index.js",
66
"repository": {
77
"type": "git",
88
"url": "git+https://github.com/letskhabar/primeupto.git"
99
},
10+
"scripts": {
11+
"test": "node index.js"
12+
},
1013
"keywords": [
1114
"prime",
1215
"math",

0 commit comments

Comments
 (0)