aboutsummaryrefslogtreecommitdiff
path: root/challenge-123/markus-holzer/raku/ch-1.raku
blob: 8d6f30568410e3ff31332929cdf2e64bec589a98 (plain)
1
2
3
4
5
6
7
8
9
10
# Write a script to find the $Nth element of "Ugly Numbers"

unit sub MAIN( Int $N );

sub factors( Int $n ) {
  if $n > 1 {
    $_, |factors $n div $_
      given ( grep $n %% *, 2..* ).first } }

say ( 1, |grep *.&factors.all ∈ ( 2, 3, 5 ), 2..* )[ $N ];