prime-number-check
v1.0.1
Published
Checks if a number is prime or not
Downloads
4
Maintainers
Readme
🌟 Installation
To use the 🔥 prime-number-check
package in your JavaScript project, you can install it via npm:
npm install prime-number-check
✨ Usage
Import the isPrime
function from the prime-number-check
package into your JavaScript code.
const isPrime = require('prime-number-check');
// Check if a number is prime
const result = isPrime(7); // Example usage
The result
variable will be ✅ true
if the input number is prime, and ❌ false
otherwise.
📦 Function
isPrime(n)
n
(Number): The number you want to check for primality.
Returns ✅ true
if the input number is prime, and ❌ false
otherwise.
🌈 Examples
Prime Numbers
const isPrime = require('prime-number-check');
console.log(isPrime(2)); // ✅ true
console.log(isPrime(3)); // ✅ true
console.log(isPrime(5)); // ✅ true
Non-Prime Numbers
const isPrime = require('prime-number-check');
console.log(isPrime(1)); // ❌ false
console.log(isPrime(4)); // ❌ false
console.log(isPrime(9)); // ❌ false
Non-Integer Input
const isPrime = require('prime-number-check');
console.log(isPrime(4.15)); // ❌ false
console.log(isPrime('2')); // ❌ false
🚀 Contributing
Contributions, bug reports, and feedback are welcome! If you encounter any issues or have suggestions for improvements, please open an issue.
📜 License
This project is licensed under the MIT License - see the LICENSE file for details.