5 variables? base 10? 100.000 combinations? Does not sound as if you need anything better than brute force... edit: didn't see the P, that would be 1.000.000 combinations, which should still be quick ...
Results that may be inaccessible to you are currently showing.
Hide inaccessible results