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.


'check if the number is pernicious
Function IsPernicious(n)
	IsPernicious = False
	bin_num = Dec2Bin(n)
	sum = 0
	For h = 1 To Len(bin_num)
		sum = sum + CInt(Mid(bin_num,h,1))
	Next
	If IsPrime(sum) Then 
		IsPernicious = True
	End If
End Function
 
'prime number validation
Function IsPrime(n)
	If n = 2 Then
		IsPrime = True
	ElseIf n <= 1 Or n Mod 2 = 0 Then
		IsPrime = False
	Else
		IsPrime = True
		For i = 3 To Int(Sqr(n)) Step 2
			If n Mod i = 0 Then
				IsPrime = False
				Exit For
			End If
		Next
	End If
End Function
 
'decimal to binary converter
Function Dec2Bin(n)
	q = n
	Dec2Bin = ""
	Do Until q = 0
		Dec2Bin = CStr(q Mod 2) & Dec2Bin
		q = Int(q / 2)
	Loop
End Function
 
'display the first 25 pernicious numbers
c = 0
WScript.StdOut.Write "First 25 Pernicious Numbers:"
WScript.StdOut.WriteLine
For k = 1 To 100
	If IsPernicious(k) Then
		WScript.StdOut.Write k & ", "
		c = c + 1
	End If
	If c = 25 Then
		Exit For
	End If
Next
WScript.StdOut.WriteBlankLines(2)
 
'display the pernicious numbers between  888,888,877 to 888,888,888 (inclusive)
WScript.StdOut.Write "Pernicious Numbers between 888,888,877 to 888,888,888 (inclusive):"
WScript.StdOut.WriteLine
For l = 888888877 To 888888888
	If IsPernicious(l) Then
		WScript.StdOut.Write l & ", "
	End If
Next
WScript.StdOut.WriteLine