This is the question
This is my solution but last test case is not running
You should declare all the variables as long, to avoid overflow.