A numerical method for calculating moments of coalescent times in finite populations with selection