Post History
Raku, 27 bytes {+([\+](1 X/1..*)...*>=$_)} Try it online! { } # Anonymous code block [\+]( ) # Get the partial sum of 1 X/ ...
Answer
#2: Post edited
- # [Raku], 27 bytes
- <!-- language-all: lang-perl6 -->
- {+([\+](1 X/1..*)...*>=$_)}
- [Try it online!][TIO-khjse7nk]
- [Raku]: https://github.com/nxadm/rakudo-pkg
- [TIO-khjse7nk]: https://tio.run/##K0gtyjH7n1upoJamYPu/WlsjOkY7VsNQIULfUE9PS1MPSNjZqsRr1v4vTqxU0AOqSssvUgDKGRr8BwA "Perl 6 – Try It Online"
- ~~~
- { } # Anonymous code block
- [\+]( ) # Get the partial sum of
- 1 X/ # 1 over each of
- 1..* # All positive integers
- ...*>=$_ # Take from the list until it is bigger than the input
- +( ) # And return the length of the list
- ~~~
This will start to suffer precision issues, but you can add `.FatRat` to [work correctly](https://tio.run/##K0gtyjH7n1upoJamYPu/WlsjOkY7VsNQzy2xJCixRCFC31BPT0tTD0jY2arEa9b@L06sVNADKk7LL1IAyhka/) (but much slower)
- # [Raku], 27 bytes
- <!-- language-all: lang-perl6 -->
- {+([\+](1 X/1..*)...*>=$_)}
- [Try it online!][TIO-khjse7nk]
- [Raku]: https://github.com/nxadm/rakudo-pkg
- [TIO-khjse7nk]: https://tio.run/##K0gtyjH7n1upoJamYPu/WlsjOkY7VsNQIULfUE9PS1MPSNjZqsRr1v4vTqxU0AOqSssvUgDKGRr8BwA "Perl 6 – Try It Online"
- ~~~
- { } # Anonymous code block
- [\+]( ) # Get the partial sum of
- 1 X/ # 1 over each of
- 1..* # All positive integers
- ...*>=$_ # Take from the list until it is bigger than the input
- +( ) # And return the length of the list
- ~~~
- This will start to suffer precision issues, but you can add `.FatRat` to [work correctly](https://tio.run/##K0gtyjH7n1upoJamYPu/WlsjOkY7VsNQzy2xJCixRCFC31BPT0tTD0jY2arEa9b@L06sVNADKk7LL1IAyhka/AcA) (but much slower)
#1: Initial revision
# [Raku], 27 bytes <!-- language-all: lang-perl6 --> {+([\+](1 X/1..*)...*>=$_)} [Try it online!][TIO-khjse7nk] [Raku]: https://github.com/nxadm/rakudo-pkg [TIO-khjse7nk]: https://tio.run/##K0gtyjH7n1upoJamYPu/WlsjOkY7VsNQIULfUE9PS1MPSNjZqsRr1v4vTqxU0AOqSssvUgDKGRr8BwA "Perl 6 – Try It Online" ~~~ { } # Anonymous code block [\+]( ) # Get the partial sum of 1 X/ # 1 over each of 1..* # All positive integers ...*>=$_ # Take from the list until it is bigger than the input +( ) # And return the length of the list ~~~ This will start to suffer precision issues, but you can add `.FatRat` to [work correctly](https://tio.run/##K0gtyjH7n1upoJamYPu/WlsjOkY7VsNQzy2xJCixRCFC31BPT0tTD0jY2arEa9b@L06sVNADKk7LL1IAyhka/) (but much slower)