Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 8 days 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 (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-11T04:01:48.000Z (10 months ago)
- Last Synced: 2024-11-22T16:52:34.691Z (2 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 ![CI](https://github.com/palashmon/random-prime-generator/actions/workflows/main.yaml/badge.svg)
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)