def binary n Math.log2(n).floor.downto(0).select {|i| n[i] == 1 }.collect {|i| 2**i}end 1.upto (100_000) { |n| binary n }
Standard input is empty
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!