bd should be defined outside of the fibonnaci() method so it is only created one time, not every time the method is called.
Type: Posts; User: Norm
bd should be defined outside of the fibonnaci() method so it is only created one time, not every time the method is called.
If you are only using the -1 as a flag, you could create one instance of BigInteger with that value and use it in all the places where the code is creating new instances with the value of -1.
See...
The snippet of code I posted says that this expression doesn't work as you expect:
mapping.get(n).equals(-1)
Why is it coded to return a -1? If the code I posted worked, then the method would return a -1 instead of a good number.
I'm not sure the posted code works. Add some debugging code like this:
//if not in memory
System.out.println("test for -1 "+ mapping.get(n)); //<<<<<<<<<...
Can you post your solution so everyone can see what the problem was and how you solved it?
Is that statement executed? What is the value of bg when it is executed?
Try debugging the code by adding some println statements to see what statements are executing and to see the values of the...
Where does the code add the other places (besides 0 and 1)?
Does it always add -1 in the other places?