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

Printing first 25 pernicious numbers #746

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

charBap
Copy link

@charBap charBap commented Oct 31, 2018

Printing first 25 pernicious numbers using bit manipulation

A pernicious number is a positive integer which has prime number of ones in its binary representation. The first pernicious number is 3 since 3 = (11)(in binary representation) and 1 + 1 = 2, which is a prime.

Properties of Pernicious Numbers :

  1. There isn’t any pernicious number which is also power of 2 because powers of two in binary form are represented as a one followed by zeros. So, 1 is not considered as a prime number.
  2. Every number of the form 2^n + 1 with n > 0 is a pernicious number as the number of ones in binary form is 2 which is prime.
  3. A number of the form 2^p – 1 with prime p is a pernicious number known as a Mersenne number .

Printing first n pernicious numbers using bit manipulation
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.

1 participant