I'd suggest DenseVector.tabulate(n)( count => .... )