Post History
Raku, 33 bytes {1+(3...{($^a...&is-prime)>=$_})} Try it online! Anonymous code block that takes a number and returns a number. Explanation { } # Anony...
Answer
#2: Post edited
- # [Raku], 33 bytes
- <!-- language-all: lang-perl6 -->
- {1+(3...{($^a...&is-prime)>=$_})}
- [Try it online!][TIO-khj20kpp]
- [Raku]: https://github.com/nxadm/rakudo-pkg
- [TIO-khj20kpp]: https://tio.run/##K0gtyjH7n1upoJamYPu/2lBbw1hPT69aQyUuEUirZRbrFhRl5qZq2tmqxNdq1v4vTqxU0AOqTcsvUjDU0zM0@A8A "Perl 6 – Try It Online"
Anonymous code block that takes a number and returns a number.
- # [Raku], 33 bytes
- <!-- language-all: lang-perl6 -->
- {1+(3...{($^a...&is-prime)>=$_})}
- [Try it online!][TIO-khj20kpp]
- [Raku]: https://github.com/nxadm/rakudo-pkg
- [TIO-khj20kpp]: https://tio.run/##K0gtyjH7n1upoJamYPu/2lBbw1hPT69aQyUuEUirZRbrFhRl5qZq2tmqxNdq1v4vTqxU0AOqTcsvUjDU0zM0@A8A "Perl 6 – Try It Online"
- Anonymous code block that takes a number and returns a number.
- ## Explanation
- ~~~
- { } # Anonymous code block
- (3...{ }) # Increment from 3 until
- ( )>=$_ # The input is less than or equal to
- $^a...&is-prime # The difference between the current number and the next prime plus 1
- 1+ # And add one to the length of this list
- ~~~
#1: Initial revision
# [Raku], 33 bytes <!-- language-all: lang-perl6 --> {1+(3...{($^a...&is-prime)>=$_})} [Try it online!][TIO-khj20kpp] [Raku]: https://github.com/nxadm/rakudo-pkg [TIO-khj20kpp]: https://tio.run/##K0gtyjH7n1upoJamYPu/2lBbw1hPT69aQyUuEUirZRbrFhRl5qZq2tmqxNdq1v4vTqxU0AOqTcsvUjDU0zM0@A8A "Perl 6 – Try It Online" Anonymous code block that takes a number and returns a number.