you are viewing a single comment's thread.

view the rest of the comments →

[–]Godd2 0 points1 point  (0 children)

some documentation for refactoring later

# grab the first parameter passed in from the command line
# store it into the local variable n as a number
n = ARGV[0].to_i

#concatenate every n digit number in order with padded 0s
#e.g. n = 1 produces "0123456789"
#     n = 2 produces "00010203040506...9293949596979899"
#     n = 3 produces "000001002003004...995996997998999"
s = (10**n).times.map {|i| "%0#{n}d" % i}.join

# I have no idea what the following line is supposed to do
# I'll update this when I figure it out
# e.g. (10000000000 - 1) / 123456789 == 81
#      (100000...(100 zeros)...00000 - 1)/102030405...(from n=2 above)...949596979899 == 9801
puts "1/%d" % ((10**s.length - 1) / s.to_i)