diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-02-29 21:51:20 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-29 21:51:20 +0000 |
| commit | 09deeb30b17ad92f1f8442cff24d04ac130fb374 (patch) | |
| tree | db93247314c0c619e226c5042295b15fc81c1d1c | |
| parent | 7f00ab106b00b2e461a5594ffa91e1a84756aebe (diff) | |
| parent | 78cba98bd90be81c4b72fd8c4fe432e2beaed57c (diff) | |
| download | perlweeklychallenge-club-09deeb30b17ad92f1f8442cff24d04ac130fb374.tar.gz perlweeklychallenge-club-09deeb30b17ad92f1f8442cff24d04ac130fb374.tar.bz2 perlweeklychallenge-club-09deeb30b17ad92f1f8442cff24d04ac130fb374.zip | |
Merge pull request #1326 from oWnOIzRi/week49
add week 49 solution
| -rw-r--r-- | challenge-049/steven-wilson/perl/ch-1.pl | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/challenge-049/steven-wilson/perl/ch-1.pl b/challenge-049/steven-wilson/perl/ch-1.pl new file mode 100644 index 0000000000..0508135940 --- /dev/null +++ b/challenge-049/steven-wilson/perl/ch-1.pl @@ -0,0 +1,33 @@ +#!/usr/bin/env perl +# Steven Wilson +# Challenge 049 Task #1 +# 24 Feb 2020 + +# Smallest Multiple + +# Write a script to accept a positive number as command line argument +# and print the smallest multiple of the given number consists of digits +# 0 and 1. + +# For example: +# For given number 55, the smallest multiple is 110 consisting of digits +# 0 and 1. + +use strict; +use warnings; +use feature qw/ say /; + +my $number = $ARGV[0]; +my $mulitplier = 1; +my $smallest_multiple; + +while (1) { + my $mulitple = $mulitplier * $number; + if ( $mulitple =~ /^[01]*$/ ) { + $smallest_multiple = $mulitple; + last; + } + $mulitplier++; +} + +say $smallest_multiple; |
