37 lines
714 B
Perl
Executable file
37 lines
714 B
Perl
Executable file
#!/usr/bin/env perl
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use FindBin;
|
|
use lib "$FindBin::RealBin/lib";
|
|
use lib 'lib';
|
|
use BinaryGap;
|
|
|
|
my $number = $ARGV[0];
|
|
if (scalar(@ARGV) != 1) {
|
|
die "Usage: $0 <integer>\n";
|
|
}
|
|
|
|
my $answer = BinaryGap::solution($number);
|
|
print "The binary gap of $number is $answer\n";
|
|
|
|
exit;
|
|
|
|
__END__
|
|
|
|
=pod
|
|
|
|
=encoding utf8
|
|
|
|
=head1 NAME
|
|
|
|
binary_gap.pl - Find longest sequence of zeros in binary representation of an integer. Script used to call BinaryGap.
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
binary_gap.pl <integer>
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
This script is used to exercise BinaryGap.pm. It takes one integer as input. It returns the binary gap (longest sequence of zeros) in the binary representation of the input number.
|