Skip to content
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

Merged
merged 9 commits into from
Jul 5, 2020
Merged

Conversation

Priyangshuyogi
Copy link
Contributor

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.

@prateekiiest
Copy link
Member

Please specify the issue name

@Priyangshuyogi
Copy link
Contributor Author

Issue #185 , interesting math algo in Competitive programming.

@prateekiiest
Copy link
Member

edit the issue name pls

@Priyangshuyogi Priyangshuyogi changed the title Myone Algorithms on Primality Test Dec 20, 2017
@Priyangshuyogi
Copy link
Contributor Author

Ok it is done.

@Priyangshuyogi
Copy link
Contributor Author

@prateekiiest long time no see.

Copy link
Member

@prateekiiest prateekiiest left a 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)
Copy link
Member

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

Copy link
Member

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).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O(root(n))

@Priyangshuyogi
Copy link
Contributor Author

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)
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here

@codeIIEST codeIIEST deleted a comment from baolao Dec 31, 2017
@Priyangshuyogi
Copy link
Contributor Author

Is it okay??

@prateekiiest
Copy link
Member

Sorry for the so long delay.

@prateekiiest prateekiiest merged commit 7ea7b3f into codeIIEST:master Jul 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants