blob: 89aaf723435ecd86fd97e22682442e75180c03fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
=pod
=head1 Question 1:
Next Palindrome Number
You are given a positive integer $N
Write a script to find out the next Palindrome Number higher than the given integer $N
=head1 Approach
Going to keep this one simple, increase $N until it becomes a palidrome.
=cut
use strict;
use warnings;
die "Need to supply a positive integer (as a command line argument)!\n" if @ARGV == 0;
my $n = shift;
die "Input must be positive\n" if $n < 1;
# Increase n until we have a new palindrome
do { ++$n; } until $n eq reverse $n;
print "$n\n";
|