https://github.com/palashmon/random-prime-generator
Generates a random prime number within a certain range
https://github.com/palashmon/random-prime-generator
generator number prime random typescript
Last synced: about 2 months ago
JSON representation
Generates a random prime number within a certain range
- Host: GitHub
- URL: https://github.com/palashmon/random-prime-generator
- Owner: palashmon
- License: mit
- Created: 2023-05-05T05:25:24.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-11T04:01:48.000Z (about 1 year ago)
- Last Synced: 2025-01-23T04:15:51.230Z (3 months ago)
- Topics: generator, number, prime, random, typescript
- Language: TypeScript
- Homepage:
- Size: 32.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Random Prime Number Generator 
A TypeScript package that generates a random prime number within a certain range.
## Installation
```bash
npm install random-prime-generator
```## Usage
To generate a random prime number, import the `generateRandomPrime` function from the `random-prime-generator` package and pass in the range in which you want the prime number to be generated.
```typescript
import { generateRandomPrime } from "random-prime-generator";const randomPrime = generateRandomPrime(1, 100);
console.log(randomPrime); // Logs a random prime number between 1 and 100 (inclusive)
```## API
### `generateRandomPrime(min: number, max: number): number`
Generates a random prime number between `min` and `max`.
#### input
- `min` - The minimum value of the range (inclusive). Must be a number.
- `max` - The maximum value of the range (inclusive). Must be a number.#### return value
- Returns a random prime number between the `min` and `max` values (inclusive) if one is found.
- or `null` if no prime number is found within the range or if the input values are invalid.## License
MIT © [Palash Mondal](https://github.com/palashmon)