My Fibonacci calculator works fine, but when going up to higher numbers the result comes up negative, as it would if it was an Integer
over its max value.
It is working with a cache java.util.Map<Integer, Long>
. Everything that goes into the Map
is exactly what is expected, but when printing it out I get e.g. for 291:
-784134397488903422
According to http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibCalcX.html, it should be:
2923602405716568564338475449381171413803636207598822186175234
It seems something goes wrong with my Long
s, but I am not sure yet, what exactly. Could someone please point me in the right direction?
Values of the Map
entries:
http://pastebin.com/uje07Ays