[ create a new paste ] login | about

Link: http://codepad.org/O8eJ058q    [ raw code | output | fork ]

Ruby, pasted on Jan 11:
1
2
3
4
5
6
7
8
9
10
11
12
i = 12345


class Integer
  def get_digit(d)
    (self / 10 ** (d-1)) % 10;
  end
end

(1..5).each do |n|
  puts i.get_digit(n)
end


Output:
1
2
3
4
5
5
4
3
2
1


Create a new paste based on this one


Comments: