First problem:
Quote:
A formula is given to calculate F as
F=F(n-1)+F(n-2)+F(n-1)*F(n-2).
This formula is not the one in your program and neither of them is Fibonacci.
So statement, program and Fibonacci are 3 different things, make your mind and choose 1 of them.
---------
When you don't understand what your code is doing or why it does what it does, the answer is
debugger.
Use the debugger to see what your code is doing. It allow you to execute lines 1 by 1 and to inspect variables as it execute, it is an incredible learning tool.
Debugger - Wikipedia, the free encyclopedia[
^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[
^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.
Advice:
return (int)(((int)pow(F0,f(F0,F1,n-1))%M)*((int)pow(F1,f(F0,F1,n)))%M)%M;
Split this line using temporary variables and 1 operation per line.
It will allow you to see what is going on with the debugger.
Question:
Quote:
i m getting run time error in this code.
Since this is not standard way of things. What compiler are you using? do you run this on your PC ? What exact message do you get?