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 + 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 – 1 with prime p is a pernicious number known as a Mersenne number .
The idea to print first n Pernicious numbers is simple.
Here is the program to print first 25 pernicious number.
Below is the implementation of the above approach.
3 5 6 7 9 10 11 12 13 14 17 18 19 20 21 22 24 25 26 28 31 33 34 35 36
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Number of factors of very large number N modulo M where M is any prime number
- Maximize a given unsigned number number by swapping bits at it's extreme positions.
- Find the largest number smaller than integer N with maximum number of set bits
- Find minimum number to be divided to make a number a perfect square
- Count number of triplets with product equal to given number with duplicates allowed
- Count number of trailing zeros in Binary representation of a number using Bitset
- Check if the binary representation of a number has equal number of 0s and 1s in blocks
- Number of ways to split a binary number such that every part is divisible by 2
- Find smallest possible Number from a given large Number with same count of digits
- Given number of matches played, find number of teams in tournament
- Number of times the largest perfect square number can be subtracted from N
- Find the number of positive integers less than or equal to N that have an odd number of digits
- Smallest number dividing minimum number of elements in the Array
- Find a number which give minimum sum when XOR with every number of array of integers
- Smallest number dividing minimum number of elements in the array | Set 2
- Largest number dividing maximum number of elements in the array
- Number which has the maximum number of distinct prime factors in the range M to N
- Find the minimum number to be added to N to make it a prime number
- Minimum number of swaps required to make a number divisible by 60
- Number of possible permutations when absolute difference between number of elements to the right and left are given
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Mithun Kumar