-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Algorithms on Primality Test #251
Conversation
Please specify the issue name |
Issue #185 , interesting math algo in Competitive programming. |
edit the issue name pls |
Ok it is done. |
@prateekiiest long time no see. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few comments.
looks good though ㊗️ 🎆
Fermat's Little Theorem: | ||
If n is a prime number, then for every a, 1 <= a < n, | ||
|
||
a^n-1 ≡ 1 (mod n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a tilde here like this a^n-1 = 1 mod(n)
Output: true | ||
|
||
Input: n = 15 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make all input / output bold and tilde for n assignment
(6k + 3). So a more efficient method is to test if n is divisible by 2 or 3, then to check through all the numbers of | ||
form 6k ± 1. | ||
|
||
Time complexity of this solution is O(√n). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O(root(n))
is it all ok now?? |
Fermat's Little Theorem: | ||
If n is a prime number, then for every a, 1 <= a < n, | ||
|
||
a^n-1 = 1 mod (n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use tilde here ``
|
||
a^n-1 = 1 mod (n) | ||
OR | ||
a^n-1 % n = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also here
Is it okay?? |
Sorry for the so long delay. |
ISSUE NUMBER - #185
SHORT DESCRIPTION
Consist of various methods to find a number is prime or not.
LOCATION
I am including this in a folder named Primality Test in math folder inside Competitive programming.
##INSIDE
All these methods are described in its perspective README.md and the implementation part is in the ScrCode.cpp file.