#!/usr/bin/ruby

class MyFraction(num, den) {

    method +(MyFraction arg) {
        MyFraction(
            self.num*arg.den + arg.num*self.den,
            self.den*arg.den
        )
    }

    method to_s {
        "[#{num}, #{den}]"
    }
}

func num(n) { n**0 }
func den(n) { n**2 }

var from = 1
var to   = 10

var sum = MyFraction(0, 1)
for i in (from .. to) {
    sum += MyFraction(num(i), den(i))
    say sum
}
