foreach (1..100) { push @_,$_; foreach (@_[1..($#_-1)]) { pop @_ and last unless ($_[-1] % $_); } } print join(" ",@_),"\n";