From 35adf4aa60eef8436f21ab4d5fd91b241d1be9f6 Mon Sep 17 00:00:00 2001 From: vinodk89 Date: Wed, 23 Jun 2021 14:08:45 +0530 Subject: Solutions for challenge 118 - Task#1 --- challenge-118/vinod-k/perl/ch-1.pl | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 challenge-118/vinod-k/perl/ch-1.pl diff --git a/challenge-118/vinod-k/perl/ch-1.pl b/challenge-118/vinod-k/perl/ch-1.pl new file mode 100644 index 0000000000..efb25316af --- /dev/null +++ b/challenge-118/vinod-k/perl/ch-1.pl @@ -0,0 +1,11 @@ +use strict; use warnings; + +my $N = $ARGV[0] || die "Please enter an integer"; + +my $N_Bin = sprintf ("%b", $N); + +if( $N_Bin eq reverse($N_Bin)){ + print "1 as binary representation of $N is $N_Bin which is Palindrome\n"; +} else { + print "0 as binary representation of $N is $N_Bin which is NOT Palindrome\n"; +} -- cgit