#!/usr/bin/perl

use feature 'say';
use warnings;
use strict;

sub primo{
	my $n =  shift;
	my $last_n = int ($n/2);
	my $res = 1;
	IN: for (my $i = 2; $i <= $last_n; $i++){
		my $p = $n/$i;
		if ($p == int $p){
			$res = 0;
			last IN;
		}
	}
	return $res;
}

sub numgen{
	my $s = time();
	my $w = 1;
	while ($w == 1){
		if (($s/2) == int ($s/2)){($s = time())}  
		else{($w = 0)}
	}
	return $s;
}

my $f_time = numgen();
say "time: $f_time";

while (1){
	if (primo($f_time)){
		if ($f_time == reverse($f_time)){
			say "Palindromo Primo: $f_time";
			exit;
		}
		else{
			$f_time += 2;
		}
	}
	else{
		$f_time += 2;
	}
}

