aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-049/southpawgeek/ch-1.pl19
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-049/southpawgeek/ch-1.pl b/challenge-049/southpawgeek/ch-1.pl
new file mode 100644
index 0000000000..4edfd257c9
--- /dev/null
+++ b/challenge-049/southpawgeek/ch-1.pl
@@ -0,0 +1,19 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use feature qw/say/;
+
+my ($int) = @ARGV;
+die "$int isn't an int! \n" if $int =~ /\D/;
+
+for (my $i = 2;;$i++){
+ my $bin = sprintf("%b", $i);
+ next if $bin == $int;
+
+ # we know it starts with 1, but make sure there's at least one 0
+ next unless $bin =~ /0+/;
+
+ say "$bin is the smallest multiple of $int with 1s *and* 0s."
+ and last
+ unless $bin % $int;
+}