UNPKG

prime-number-check

Version:
101 lines (68 loc) 2.92 kB
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="160" viewBox="0 0 800 160"> <!-- Background rectangle --> <rect width="100%" height="160" rx="0" ry="0" fill="#0366d6" /> <!-- Package name --> <text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" fill="#ffffff" font-size="40" font-weight="bold"> Prime Number Check </text> </svg> <h1>🔥 prime-number-check 🔥</h1> <p>🚀 A lightweight npm package to check if a number is prime or not. 🚀</p> <p align="center"> <a href="https://github.com/AnirudhaPatil-1/prime-check-package/issues"> <img alt="GitHub issues" src="https://img.shields.io/github/issues/AnirudhaPatil-1/prime-check-package"> </a> <a href="https://github.com/AnirudhaPatil-1/prime-check-package/stargazers"> <img alt="GitHub stars" src="https://img.shields.io/github/stars/AnirudhaPatil-1/prime-check-package"> </a> <a href="https://github.com/AnirudhaPatil-1/prime-check-package/blob/main/LICENSE"> <img alt="GitHub license" src="https://img.shields.io/github/license/AnirudhaPatil-1/prime-check-package"> </a> </p> --- ## 🌟 Installation To use the 🔥 `prime-number-check` package in your JavaScript project, you can install it via npm: ```bash npm install prime-number-check ``` ## ✨ Usage Import the `isPrime` function from the `prime-number-check` package into your JavaScript code. ```javascript 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 ```javascript const isPrime = require('prime-number-check'); console.log(isPrime(2)); //true console.log(isPrime(3)); //true console.log(isPrime(5)); //true ``` ### Non-Prime Numbers ```javascript const isPrime = require('prime-number-check'); console.log(isPrime(1)); //false console.log(isPrime(4)); //false console.log(isPrime(9)); //false ``` ### Non-Integer Input ```javascript 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](https://github.com/AnirudhaPatil-1/prime-check-package/issues). ## 📜 License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. --- <footer align="center"> <p> Made with ❤️ by Anirudha Patil</p> </footer>