numof 1 bits in 0 to 255 by gerut

for($i = 0; $i <= 255; $i++)
{
$var =   sprintf '%b', $i;
$anzahl = $var =~ tr/1//;
print $anzahl;
}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page