Ruby-ize for loop - counting all the n-digit numbers that contain the digit 5 anywhere
I would use recurence in place of the loop - it is easier to understand the logic behind it then:

def number_containing_5(pwr)
  return 0 if pwr == 0
  number_containing_5(pwr-1) * 9 + 10**(pwr-1)
end