TheAlgorithms / Rust

All Algorithms implemented in Rust
MIT License
22.92k stars 2.24k forks source link

feat: add fermats little theorem #809

Closed saahil-mahato closed 1 month ago

saahil-mahato commented 1 month ago

Description

Fermat Primality Test Implementation

This PR introduces an implementation of the Fermat Primality Test in Rust. The algorithm leverages Fermat's Little Theorem, which states that if ( p ) is a prime number, then for any integer ( a ) such that ( 1 < a < p - 1 ), it holds that:

a^(p−1) ≡ 1 (mod p)

Key Features:

Test Cases:

This implementation provides a fast, probabilistic approach to primality testing, making it suitable for applications in cryptography and numerical analysis.

Type of change

Please delete options that are not relevant.

Checklist:

codecov-commenter commented 1 month ago

Codecov Report

Attention: Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.36%. Comparing base (bc8d6fa) to head (dfcdea6). Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
src/math/fermats_little_theorem.rs 96.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #809 +/- ## ========================================== + Coverage 95.32% 95.36% +0.04% ========================================== Files 310 312 +2 Lines 22484 22698 +214 ========================================== + Hits 21433 21647 +214 Misses 1051 1051 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

saahil-mahato commented 1 month ago

@vil02 I have resolved the comments. Please review and let me know if anything is missing.