in reply to Re^2: Elegantly map fizz to buzz
in thread Elegantly map fizz to buzz
to generalize the problem by passing the moduli along as arguments.
If I've understood the task correctly, I think you're working the math too hard:
sub x{ my $v=shift; my $t=0; $t += !!($v%$_) for @_; return $t!=@_ };; sub fn{ my$n; x($_, @_) and $n+=$_ for 1 .. shift; $n };; print fn( 10, 3, 5 );; 33 print fn( 10, 3, 5, 7 );; 40 print fn( 100000, 3, 5, 7, 74017, 74027, 74047, 74077 );; 2714660445
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Elegantly map fizz to buzz
by oiskuu (Hermit) on May 18, 2016 at 18:06 UTC | |
by BrowserUk (Patriarch) on May 18, 2016 at 18:25 UTC |