Re: Sequence items to a single number ? How to achieve ?

new topic     » goto parent     » topic index » view thread      » older message » newer message

try this

include std/math.e 
integer d = 5  --your decimal number 
 
sequence b = {} 
 
while 1 do 
    b = append(b,mod(d,2)) 
    d = floor(d/2) 
    if d = 0 then 
        exit 
    end if 
end while 
 
puts(1,"{") 
for i = 1 to length(b) do 
    printf(1,"%d",b[i]) 
    if i != length(b) then 
        puts(1,",") 
    end if 
end for 
puts(1,"}") 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu