puts "Enter a maximum value:" max = gets.chomp.to_f count = 1 number = 0 while number < max count += 1 number = 2 ** count end number /= 2 count -= 1 puts "2^" + count.to_s + " = " + number.to_s + " is the highest power of 2 less than " + max.to_s