in reply to Newbie question
My 2 cents CDN, for what it's worth. (We don't have pennies anymore, so 0.)
$ perl -e' my @input = ( -222, -221, -21, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 +, 144 ); sub oddDigitSum { my @ans; for ( @_ ) { my $sum; $sum += $_ for /\d/g; $sum % 2 && push @ans, $_; } return @ans; } print "@{[ oddDigitSum @input ]}\n"; '
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Newbie question
by oldB51 (Sexton) on Aug 24, 2022 at 07:07 UTC |