Ruby - Enumerable - reduce

  • + 0 comments

    Fixnum and BigNum are deprecated, and the test code used for this exercise is returning an error because of that.

    https://apidock.com/ruby/Fixnum

    https://apidock.com/ruby/Bignum

    workarund:

    Fixnum = Integer
    BigNum = Integer
    def sum_terms(n)
      (1..n).reduce(0) { |current, x| (x*x + 1) + current}
    end