Post History
Scala, 55 bytes (Stream from 1 map 1.0./scanLeft.0)(_+_)indexWhere _.<= Try it online! Written in a more sane manner: n => Stream.from(1).map(1.0/_).scanLeft(0.0)(_+_).indexWhere(_ &g...
#1: Initial revision
# [Scala], 55 bytes
<!-- language-all: lang-scala -->
(Stream from 1 map 1.0./scanLeft.0)(_+_)indexWhere _.<=
[Try it online!][TIO-km2vjrh4]
[Scala]: http://www.scala-lang.org/
[TIO-km2vjrh4]: https://tio.run/##JcuxCsIwEAbgvU/xjw1CbMBJrOBY0MnBsZztBSvNNSSHFMRnj6DTN315oJnKcn/yoLjQJOBVWcaMU4x4VxXwohl@j04U7fFPqa@amAJ8WgIcAkU429htHkjO7NU2pu43vZlk5PX24MTo7aEtQEyT6Cy1gy7Y/aY31ad8AQ "Scala – Try It Online"
Written in a more sane manner:
```scala
n => Stream.from(1).map(1.0/_).scanLeft(0.0)(_+_).indexWhere(_ >= n)
```
Explanation:
```scala
(
Stream from 1 //Make an infinite list of integers, starting at 1
map 1.0./ //Find the reciprocal of each (divide 1.0)
scanLeft .0)(_+_) //Sum each partial sequence
indexWhere //Find the index where
_.<= //n (underscore) is less than or equal to a partial sum
```
