Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
34
Task/Population-count/Yabasic/population-count.basic
Normal file
34
Task/Population-count/Yabasic/population-count.basic
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
print "Pop count (3^x): "
|
||||
|
||||
for i = 0 to 29
|
||||
print population(3^i);
|
||||
next
|
||||
print "\n"
|
||||
|
||||
print "Evil: "
|
||||
EvilOdious(30)
|
||||
print "\n"
|
||||
|
||||
print "Odious: "
|
||||
EvilOdious(30, 1)
|
||||
print "\n"
|
||||
|
||||
sub EvilOdious(limit, type)
|
||||
local i, count, eo
|
||||
|
||||
repeat
|
||||
eo = mod(population(i), 2)
|
||||
if (type and eo) or (not type and not eo) count = count + 1 : print i;
|
||||
i = i + 1
|
||||
until(count = limit)
|
||||
end sub
|
||||
|
||||
sub population(number)
|
||||
local i, binary$, popul
|
||||
|
||||
binary$ = bin$(number)
|
||||
for i = 1 to len(binary$)
|
||||
popul = popul + val(mid$(binary$, i, 1))
|
||||
next
|
||||
return popul
|
||||
end sub
|
||||
Loading…
Add table
Add a link
Reference in a new issue