3 ms·
How much they've made so far, with scala: scala> def income(n_users:Int) = (1 to n_users) map(i => (i-1)*.001) reduceLeft(_+_) income: (Int)Double scala>
by wooby 17y ago
How much they've made so far, with scala:
scala> def income(n_users:Int) = (1 to n_users) map(i => (i-1)*.001) reduceLeft(_+_)
income: (Int)Double
scala> income(2901)
res0: Double = 4206.45
- swolchok 17y agoYou need to round the intermediate values down like they seem to be doing.