#!/usr/bin/ruby

#
## https://rosettacode.org/wiki/Catalan_numbers/Pascal%27s_triangle
#

func catalan(num) {
  var t = [0, 1];
  range(1, num).map { |i|
    range(i, 1, -1).each {|j| t[j] += t[j-1]};
    t[i+1] = t[i];
    range(i+1, 1, -1).each {|j| t[j] += t[j-1]};
    t[i+1] - t[i];
  }
}

say catalan(15).join(' ');
