UPDATE: C(n, k) means Binomial Coefficient
I'm dealing with a number theory problem. I've transformed the big problem into a simple problem: How to calculate C(n,k)%3
, for which n<=10^15. There are about m ( <= 10 000 )
data-set needed to calculate within 1 second.
The way I solve it is using the Lucas' theorem
. It's O(m log n)
. And it's fast enough to solve the problem. But I'm wondering if there is a better solution to this problem, and even to n <= 10^100
or m <= 1 000 000
?
Thanks a lot!