fork download
  1. sub is_prime { ($_[0] == 2 ? 1 : ($_[0] % 2 ? not grep{ $_[0] % ($_ * 2 + 1) == 0 } (1..(sqrt($_[0]) / 2)) : 0)) }
  2.  
  3. my $n = 2;
  4. for(1..50){
  5. $n++ while(($n ne reverse $n) or not is_prime($n));
  6. print $n++, "\n";
  7. }
Success #stdin #stdout 0.01s 4596KB
stdin
Standard input is empty
stdout
2
3
5
7
11
101
131
151
181
191
313
353
373
383
727
757
787
797
919
929
10301
10501
10601
11311
11411
12421
12721
12821
13331
13831
13931
14341
14741
15451
15551
16061
16361
16561
16661
17471
17971
18181
18481
19391
19891
19991
30103
30203
30403
30703