in reply to What am I missing?
The least intrusive change to your program to get it working is this:
foreach $i (@f) { @n = grep {$_ % $i != 0 || $_ == $i } @n; } [download]