created algorithm to solve pascals triangle