27 lines
622 B
Text
27 lines
622 B
Text
with javascript_semantics
|
|
function pop_count(atom n)
|
|
if n<0 then ?9/0 end if
|
|
integer res = 0
|
|
while n!=0 do
|
|
res += and_bits(n,1)
|
|
n = floor(n/2)
|
|
end while
|
|
return res
|
|
end function
|
|
|
|
printf(1,"3^x pop_counts:%v\n",{apply(apply(true,power,{3,tagset(29,0)}),pop_count)})
|
|
|
|
procedure eo(integer b0, string name)
|
|
sequence s = repeat(0,30)
|
|
integer k=0, l=1
|
|
while l<=30 do
|
|
if and_bits(pop_count(k),1)=b0 then
|
|
s[l] = k
|
|
l += 1
|
|
end if
|
|
k += 1
|
|
end while
|
|
printf(1,"%s numbers:%v\n",{name,s})
|
|
end procedure
|
|
eo(0," evil")
|
|
eo(1,"odious")
|