Improve pascal function to pass coursera test cases