and 1 contributors

- NAME
- SYNOPSIS
- DESCRIPTION
- THANKS Bruno Buss and all community of rio.pm.org
- AUTHOR
- COPYRIGHT
- SEE ALSO

# NAME

Math::Palindrome - Tool to manipulate palindromes numbers.

# SYNOPSIS

```
use Math::Palindrome qw/is_palindrome
next_palindrome
previous_palindrome
increasing_sequence
decreasing_sequence
palindrome_after
palindrome_before/;
my $n = 42; #We sujest never use '05', just '5'
is_palindrome($n) ? print "TRUE" :print "FALSE"; # false!
print next_palindrome($n); # 44
print previous_palindrome($n); # 33
#to increasing_sequence and decreasing_sequence insert
# the size of sequence
my @sequence_01 = increasing_sequence(5, $n); # 44 55 66 77 88
#or
my @sequence_01 = increasing_sequence(5); # 1 2 3 4 5
# default is 0
my @sequence_02 = decreasing_sequence(5, $n); # 33 22 11 9 8
#or
my @sequence_02 = decreasing_sequence(5); # 99 88 77 66 55
#default is 100
my $last = palindrome_after(5, $n); # 88
# is the same $last = increasing_sequence(5, $n);
# this is valid too
my $last = palindrome_after(5); # 5
my $first = palindrome_before(5, $n); # 8
# is the same $first = decreasing_sequence(5, $n);
# this is valid too
my $first = palindrome_before(5); # 55
```

# DESCRIPTION

This module is a alternative agains Math::NumSeq::Palindromes. Can use this to find and confirm palindrome numbers. In my tests it's work correctly with small and large numbers. The most largest numbers was 9,99999 * 10^19. But, I think that its involved a memory capacity. In this module, I used a deterministc method, maybe you can think that is a heuristic, but not. I'm ready for fix a report bugs.

## is_palindrome

```
Usage : is_palindrome($n)
Purpose : verify if the number is palindrome or not
Returns : return 1 if true or 0 if false
Comment : is the same:
($n == reverse $n) ? return 1 : return 0
```

## next_palindrome

```
Usage : next_palindrome($n);
Purpose : return the next palindrome number after $n
```

## previous_palindrome

```
Usage : previous_palindrome($n);
Purpose : return the previous palindrome number before $n
```

## increasing_sequence

```
Usage : increasing_sequence($size, $first_value);
Purpose : return the crescent sequence of palindrome number after $n
Argument : $size is the number of palindromes that you want
: $first_value is the number where it start to work, default it is 0 and never return the $first_value
Throws : Don't return $first_value even it's palindrome
Comment : Use with array.
```

## decreasing_sequence

```
Usage : decreasing_sequence($size, $first_value);
Purpose : return the decrescent sequence of palindrome number beforer $n
Argument : $size is the number of palindromes that you want
: $first_value is the number where it start to work, default it is 100 and never return the $first_value
Throws : Don't return $first_value even it's palindrome
Comment : Use with array;
```

## palindrome_after

```
Usage : palindrome_after($size, $first_value);
Purpose : return the last number of crescent sequence of palindrome number beforer $n
Argument : $size is the number of palindromes that you want
: $first_value is the number where it start to work, default it is 100 and never return the $first_value
Throws : Don't return $first_value even it's palindrome
Comment : Is like:
$n = increasing_sequence($s, $p);
```

## palindrome_before

```
Usage : palindrome_before($size, $first_value);
Purpose : return the last number of decrescent sequence of palindrome number beforer $n
Argument : $size is the number of palindromes that you want
: $first_value is the number where it start to work, default it is 0 and never return the $first_value
Throws : Don't return $first_value even it's palindrome
Comment : Is like:
$n = decreasing_sequence($s, $p);
```

# THANKS Bruno Buss and all community of rio.pm.org

# AUTHOR

```
Aureliano C. P. Guedes
CPAN ID: acpguedes
guedes.aureliano@gmail.com
```

# COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

# SEE ALSO

perl(1).