Factoring + triangular numbers algorithms.