diff options
| -rwxr-xr-x | challenge-007/joelle-maslak/perl5/ch-1.pl | 32 | ||||
| -rwxr-xr-x | challenge-007/joelle-maslak/perl6/ch-1.p6 | 15 |
2 files changed, 47 insertions, 0 deletions
diff --git a/challenge-007/joelle-maslak/perl5/ch-1.pl b/challenge-007/joelle-maslak/perl5/ch-1.pl new file mode 100755 index 0000000000..cc5b3940ae --- /dev/null +++ b/challenge-007/joelle-maslak/perl5/ch-1.pl @@ -0,0 +1,32 @@ +#!/usr/bin/env perl +use v5.26; +use strict; +use warnings; + +# Turn on method signatures +use feature 'signatures'; +no warnings 'experimental::signatures'; + +if ( @ARGV > 1 ) { die("Provide letters to use and (optionally) filename") } +my $MAX = $ARGV[0] // 50; + +# +# Copyright (C) 2019 Joelle Maslak +# All Rights Reserved - See License +# + + +MAIN: { + for (my $i=1; $i<=$MAX; $i++) { # We know via math that 0 is not Niven + say $i if ! ($i % sum( [ split //, $i ])); + } +} + +sub sum($list) { + my $sum = 0; + foreach my $i (@$list) { + $sum += $i; + } + return $sum; +} + diff --git a/challenge-007/joelle-maslak/perl6/ch-1.p6 b/challenge-007/joelle-maslak/perl6/ch-1.p6 new file mode 100755 index 0000000000..e430395632 --- /dev/null +++ b/challenge-007/joelle-maslak/perl6/ch-1.p6 @@ -0,0 +1,15 @@ +#!/usr/bin/env perl6 +use v6; + +# +# Copyright © 2019 Joelle Maslak +# All Rights Reserved - See License +# + +sub MAIN(UInt:D $max = 50) { + for 0..$max -> $i { + say $i if $i %% [+] $i.comb; + } +} + + |
