Advertisement
guedes_acp

Ultima tentativa

May 1st, 2014
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.62 KB | None | 0 0
  1. #!/usr/env/perl
  2.  
  3. use warnings;
  4. use strict;
  5. use feature 'say';
  6. use Math::Prime::Util qw/is_prime next_prime/;
  7. use Math::Palindrome qw/next_palindrome is_palindrome/;
  8.  
  9. sub main{
  10.     my $time = time();
  11.     say "Current time: $time";
  12.     $time = next_palindrome($time);
  13.    
  14.     while(!is_prime($time)){
  15.         $time = next_palindrome($time);
  16.        
  17.         if (is_palindrome($time) and !is_prime($time)){
  18.             $time = next_prime($time);
  19.             if(!is_palindrome($time)){$time = next_palindrome($time)}
  20.         }
  21.        
  22.         if((reverse $time) % 2 == 0){
  23.             $time = reverse $time;
  24.             $time++;
  25.             $time = reverse $time;
  26.         }
  27.     }
  28.     say "$time";
  29. }
  30. main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement