func ham_gen { var s = [[1], [1], [1]] var m = [2,3,5] func { var n = [s[0][0], s[1][0], s[2][0]].min { |i| s[i].shift if (s[i][0] == n) s[i].append(n * m[i]) } <<^3return n }}var h = ham_gen()var i =20;say i.of { h() }.join(' '){ h() } << (i+1..^1691)say h()