So it turns out there is a better algorithm for this. The algorithm is \$10^n - 9^n\$ and you can find an explanation of it over on Mathematics ExchangeMathematics Exchange. The improved algorithm completely removed my need for a loop, so I separated the test (printing) logic from the actual function and "ruby-ized" that loop instead.
def count_of_numbers_containing_5(power)
(10**power)-(9**power)
end
def test_it(pwr)
(1..pwr).each {|i| puts count_of_numbers_containing_5(i)}
end
test_it 20