Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
35
Task/Population-count/BASIC256/population-count.basic
Normal file
35
Task/Population-count/BASIC256/population-count.basic
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
print "Pop cont (3^x): ";
|
||||
for i = 0 to 29
|
||||
print population(3^i); " "; #los últimos números no los muestra correctamente
|
||||
next i
|
||||
|
||||
print : print
|
||||
print "Evil numbers: ";
|
||||
call EvilOdious(30, 0)
|
||||
|
||||
print : print
|
||||
print "Odious numbers: ";
|
||||
call EvilOdious(30, 1)
|
||||
end
|
||||
|
||||
subroutine EvilOdious(limit, type)
|
||||
i = 0 : cont = 0
|
||||
|
||||
do
|
||||
eo = (population(i) mod 2)
|
||||
if (type and eo) or (not type and not eo) then
|
||||
cont += 1 : print i; " ";
|
||||
end if
|
||||
i += 1
|
||||
until (cont = limit)
|
||||
end subroutine
|
||||
|
||||
function population(number)
|
||||
popul = 0
|
||||
|
||||
binary$ = tobinary(number)
|
||||
for i = 1 to length(binary$)
|
||||
popul += int(mid(binary$, i, 1))
|
||||
next i
|
||||
return popul
|
||||
end function
|
||||
Loading…
Add table
Add a link
Reference in a new issue