knb's blog

By knb, 9 years ago, In English

I have a non linear recurrence relation a(n)=(n-1)*(a(n-1)+a(n-2)).How can I calculate a(n)%MOD in O(log(n)) time? Base conditions:-a(0)=0,a(1)=1

Full text and comments »

  • Vote: I like it
  • +6
  • Vote: I do not like it