https://github.com/dustwinter/primechecker
A function that returns True if the input number is prime, False if not.
https://github.com/dustwinter/primechecker
algorithm algorithms math mathematical-programming mathematics prime-numbers
Last synced: 2 months ago
JSON representation
A function that returns True if the input number is prime, False if not.
- Host: GitHub
- URL: https://github.com/dustwinter/primechecker
- Owner: DustWinter
- Created: 2024-09-14T10:14:10.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-20T16:57:12.000Z (12 months ago)
- Last Synced: 2025-03-12T01:34:49.547Z (9 months ago)
- Topics: algorithm, algorithms, math, mathematical-programming, mathematics, prime-numbers
- Language: Python
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PrimeCheck1
Complexity = √n
A simple Python function that checks if an odd number is prime using a custom formula.
## How to Use
```python
from PrimeCheck import PrimeCheck
number = 17
is_prime = PrimeCheck1(number) # Returns True
```
## How it Works
Uses the formula: `(((n-1)/2)-a) / ((2*a)+1)`
- If the formula ever results in a whole number, the input is not prime
- Otherwise, the number is prime
-
# PrimeCheck2
Complexity = √n
A simple Python function that checks if an odd number is prime using a custom formula.
## How to Use
```python
from PrimeCheck import PrimeCheck
number = 17
is_prime = PrimeCheck2(number) # Returns True
```
## Updates
The floating-point inaccuracies in PrimeCheck1 are now avoided. Same logic reasoning as PrimeCheck1