while (my ($x, $y, $z) = @{ $iter->next // [] }) { push @wants, map { { join(', ', $x, $y, $z) => $_ } } grep { is_approximately_an_integer( @$_ ) } [ poly_roots( poly_derivative( # expanded form of x*(x - $x)*(x - $y)*(x - $z) 1, -$x - $y - $z, $x*$y + $x*$z + $y*$z, -$x*$y*$z, 0 ) ) ]; } #### my @cnt; my $seq= 0; my $x = $cnt[0]; my $y = $cnt[1]; my $z = $cnt[2]; while( @cnt = $iter->() ) { #printf "%d) %s\n", ++$seq, join ' + ', @cnt map { { join(', ', $x, $y, $z) => $_ } } grep { is_approximately_an_integer( @$_ ) } [ poly_roots( poly_derivative( # expanded form of x*(x - $x)*(x - $y)*(x - $z) 1, -$x - $y - $z, $x*$y + $x*$z + $y*$z, -$x*$y*$z, 0 ) ) ]; }