- Code: Select all
#!/usr/bin/perl
$max = 50;
while (((!defined $i ? $i = 1 : $i++) and ($i > $max ? exit() : $i) and ($j = 1)) or (!$i))
{
while ((!defined $j ? $j = 1 : $j++) and ($j > $i ? last : $j) and ($j == $i ? print "$i\n" : $i) and ($i % $j != 0 ? $i : last))
{
}
}
Or, when spaced out,
- Code: Select all
#!/usr/bin/perl
$max = 50;
while (
(
(!defined $i ? $i = 1 : $i++)
and
($i > $max ? exit() : $i)
and
($j = 1)
)
or
(!$i)
)
{
while (
(!defined $j ? $j = 1 : $j++)
and
($j > $i ? last : $j)
and
($j == $i ? print "$i\n" : $i )
and
($i % $j != 0 ? $i : last)
)
{
}
}
Output:
drusepth@bitdumpster:~$ perl lolwat.pl
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47

