RosettaCodeData/Task/Hamming-numbers/Sidef/hamming-numbers.sidef

22 lines
351 B
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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])
} << ^3
return n
}
}
var h = ham_gen()
var i = 20;
say i.of { h() }.join(' ')
{ h() } << (i+1 ..^ 1691)
say h()