I would prefer to do this without having to calculate every previous row of Pascal's triangle first. I'm familiar with the algorithm for calculating the nth row of Pascal's triangle directly, where you multiply each previous result by n/1, then (n-1)/2, then (n-2)/3... so on. I can't really calculate the entries of the row directly because they get too big for a 64-bit integer. Problem is, I also don't know how to apply that algorithm with modular arithmetic, because that would involve modular division and 10 isn't prime. Am I missing something obvious here?