Skip to content

Update PalindromicPrime.java - #701

Merged
yanglbme merged 1 commit into
TheAlgorithms:masterfrom
IvanKuzaev:patch-1
Feb 3, 2019
Merged

Update PalindromicPrime.java#701
yanglbme merged 1 commit into
TheAlgorithms:masterfrom
IvanKuzaev:patch-1

Conversation

@IvanKuzaev

Copy link
Copy Markdown
Contributor

Method prime(num) uses only odd numbers from 3 to square root of num as divisors.
In method functioning(y) we iterate over odd numbers as all even numbers (except of 2) are not prime.
In method functioning(y) we check at first if the number is palindrome and then if it's prime, so we don't have to call the heavy prime() method for every number.
The speed of searching palindromic primes is significantly increased.

Method prime(num) uses only odd numbers from 3 to square root of num as divisors.
In method functioning(y) we iterate over odd numbers as all even numbers (except of 2) are not prime.
In method functioning(y) we check at first if the number is palindrome and then if it's prime, so we don't have to call the heavy prime() method for every number.
The speed of searching palindromic primes is significantly increased.

@yanglbme yanglbme left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@IvanKuzaev Thanks for your change :)

@yanglbme
yanglbme merged commit f869601 into TheAlgorithms:master Feb 3, 2019
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.

3 participants