Rewriting expressions using GCF and multiplication