Skip to content

Commit

Permalink
V2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vimal-verma committed Jun 8, 2020
1 parent 85fc2b3 commit 784db86
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ primeupto is an math library for JavaScript and Node.js. It help you to find all
- find all prime number from m to n. // comming soon
- find number of prime upto n.
- find number of prime from m to n.
- find a number is Prime or not.
- Can be used in command line as well.
- Runs on any JavaScript engine.
- Is easily extensible.
Expand All @@ -31,16 +32,20 @@ Install primeupto using [npm](https://www.npmjs.com/package/primeupto):


```js
const {primeupto,primelength} = require('primeupto');
const {primeupto,primelength,isPrime} = require('primeupto');

console.log(primeupto(5)); // 2,3,5
console.log(primeupto(5)); // 2,3,5
console.log(primelength(5)); // 3
console.log(primeupto(34)); // 2,3,5,7,11,13,17,19,23,29,31
console.log(isPrime(5)); // true
console.log(primeupto(34)); // 2,3,5,7,11,13,17,19,23,29,31
console.log(primelength(34)); // 11
console.log(primeupto(25)); // 2,3,5,7,11,13,17,19,23
console.log(isPrime(34)); // false
console.log(primeupto(25)); // 2,3,5,7,11,13,17,19,23
console.log(primelength(25)); // 9
console.log(primeupto(53)); // 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53
console.log(isPrime(25)); // false
console.log(primeupto(53)); // 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53
console.log(primelength(53)); // 16
console.log(isPrime(53)); // true

```

Expand Down
26 changes: 25 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,29 @@ module.exports.primelength = max =>
}
}
return primes.length;
}
};


module.exports.isPrime = num =>{
if (num == 2) {
return true;
}
else if(num > 2){
let flag = false;
for (var i = 2; i < num; i++) {

if (num % i == 0 ) {
return false;
}
else {
flag = true;
}
}
if(flag == true){
return true;
}
}
else {
return false;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "primeupto",
"version": "1.1.1",
"version": "2.0.0",
"description": "primeupto",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit 784db86

Please sign in to comment.