$| = 1; $count = 0; for ($i = 0; $i < 10000; $i++) { if (is_lychell($i,0)) { print "$i\n"; $count++; } } print "Total: $count\n"; exit; sub is_lychell { my ($n,$depth) = @_; $s = $n + reverse($n); if ($s eq reverse($s)) { return 0; } elsif ($depth == 49) { return 1; } else { return is_lychell($s,$depth+1); } }