"improved "function n" adding a better control to the sorting of the 3 factor multiplications