class Modulo
  include Comparable

  def initialize(n = 0, m = 13)
    @n, @m = n % m, m
  end

  def to_i
    @n
  end

  def <=>(other_n)
    @n <=> other_n.to_i
  end

  [:+,:-,:*,:**].each do |meth|
    define_method(meth) { |other_n| Modulo.new(@n.send(meth, other_n.to_i), @m) }
  end

  def coerce(numeric)
    [numeric, @n]
  end

end


x, y = Modulo.new(10), Modulo.new(20)

p x > y          
p x == y         
p [x,y].sort     
p x + y          
p 2 + y          
p y + 2          

p x**100 + x +1