I want to find the Nth number of the repeat equation
T(n)=T(n-1)+3T(n-2)+3T(n-3)+(n-4),T(1)=T(4)=1,T(2)=T(3)=3
therefore, if you entered 2.5.9 as input, the output should be T(2)=3,T(5)=20,T(9)=695
what I did was create an array of size equal to the maximum value of all input values, and save the solution T (i) in index i. Then look into the array for a specific index. for example, array [3] for T (3), array [5] for T (5), etc.
The code worked fine until the maximum number is greater than the maximum integer value system may contain ie
Integer.MAXValue.
Since the index of the array can only be an integer, then if it is a number n=1855656959555656, then what should be the best way to find a solution
T(1855656959555656)? since i obviously cannot create an arraysize=1855656959555656..
I even tried BigInteger out java.Math, but without success. I have to find some other approach. Suggest a few ideas.
thank
source
share