Hi all,

I want to write a method to tranlate base 10 number
into base 2 number. I want to call the method within
itself. But it doesn't work. What is the right way  
to do something like this?

Thanks,

Li

#####
def ten_to_two(num1)    
    @array=[]      
     if num1>2        
          first,second=num1.divmod(2)
          @array<<second  
          
        #call the method itself
        ten_to_two(first)

     else
          @array<<second<<first     
     end  
    return @array.reverse           
end 
  
puts ten_to_two(5)

##output
>ruby assembly1.rb
nil
nil
>Exit code: 0

  



 
____________________________________________________________________________________
8:00? 8:25? 8:40? Find a flick in no time 
with the Yahoo! Search movie showtime shortcut.
http://tools.search.yahoo.com/shortcuts/#news