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.



Task
 display the first   25   pernicious numbers   (in decimal).
 display all pernicious numbers between   888,888,877   and   888,888,888   (inclusive).
 display each list of integers on one line   (which may or may not include a title).


See also
 Sequence   A052294 pernicious numbers on The On-Line Encyclopedia of Integer Sequences.
 Rosetta Code entry   population count, evil numbers, odious numbers.


 
 
primes : 0b0010100000100000100010100010000010100000100010100010100010101100 
 
| the first 25 pernicious numbers
 
 
       $T                                | clear string
       num_pn                            | set to zero
       2 n                               | start at 2
       5 hi_bit
       if num_pn LT 25                     
          call popcount                  | count ones
          if primes bit pop_cnt          | if pop_cnt bit of bit vector primes is one
             + num_pn                    | inc number of pernicious numbers
             ~ n $S                      | convert to decimal string
             + ' ' $S                    | pad a space 
             + $S $T                     | add to string $T
          endif
          + pop_cnt                      | next number (odd) has one more bit than previous (even)
          + n                            | next number
          if primes bit pop_cnt
             + num_pn
             ~ n $S
             + ' ' $S
             + $S $T
          endif
          + n
          goif                           | go back to if
       endif
       $T []                             | display numbers 
 
 
 
| pernicious numbers in range 888888877 .. 888888888
 
       $T                                | clear string
       num_pn                            | set to zero
       888888876 n                       | start at 888888876
       29 hi_bit
       if n LE 888888888                     
          call popcount                  | count ones
          if primes bit pop_cnt          | if pop_cnt bit of bit vector primes is one
             + num_pn                    | inc number of pernicious numbers
             ~ n $S                      | convert to decimal string
             + ' ' $S                    | pad a space 
             + $S $T                     | add to string $T
          endif
          + pop_cnt                      | next number (odd) has one more bit than previous (even)
          + n                            | next number
          if primes bit pop_cnt
             + num_pn
             ~ n $S
             + ' ' $S
             + $S $T
          endif
          + n
          goif                           | go back to if
       endif
       $T []                             | display numbers 
 
       stop
 
 
 
popcount                                 | count ones in bit field
       pop_cnt                           | pop_cnt to zero
       1 bit_num                         | only count even numbers so skip bit 0
       if bit_num LE hi_bit
          if n bit bit_num
             + pop_cnt
          endif
          + bit_num
          goif
       endif
       return
 
 