aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Wilson <steven1170@zoho.eu>2020-02-29 15:56:39 +0000
committerSteven Wilson <steven1170@zoho.eu>2020-02-29 15:56:39 +0000
commit78cba98bd90be81c4b72fd8c4fe432e2beaed57c (patch)
treed00149e0d47fc4812c581b8ec6c0d1e3f258cc99
parent4a0e7a230f9da4ca47237cf6323ff3fb07757889 (diff)
downloadperlweeklychallenge-club-78cba98bd90be81c4b72fd8c4fe432e2beaed57c.tar.gz
perlweeklychallenge-club-78cba98bd90be81c4b72fd8c4fe432e2beaed57c.tar.bz2
perlweeklychallenge-club-78cba98bd90be81c4b72fd8c4fe432e2beaed57c.zip
add week 49 solution
-rw-r--r--challenge-049/steven-wilson/perl/ch-1.pl33
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;