Posts

Showing posts with the label pernicious numbers

Pernicious numbers | Rosetta Code | #15

URL to the problem page:  http://rosettacode.org/wiki/Pernicious_numbers A pernicious number is a positive integer whose population count is a prime. The population count is the number of ones in the binary representation of a non-negative integer. Example 22 (which is 10110 in binary) has a population count of 3, which is prime, and therefore 22 is a pernicious number. Display the first 25 pernicious numbers (in decimal). Display all pernicious numbers between 888,888,877 and 888,888,888 (inclusive). #include   <iostream> using   namespace   std ; int   main () {      int  cnt =  0 , cnt2, cnt3, tmp,  binary [ 8 ];     cout <<  "First 25 pernicious numbers are:"  << endl;      for  ( int  i =  3 ; cnt <  25 ; i++) {     ...
My photo
Ercan Tomac
instagram.com/ercantomac