Java icon indicating copy to clipboard operation
Java copied to clipboard

Fibonacci giving strange output if giving large numbers.

Open debasishbsws opened this issue 3 years ago • 5 comments

Describe the bug In Fibonacci, all the functions are taking input as int and give output as int. But if we give a big int as input the corresponding Fibonacci number will not fit inside an int variable.

output datatype should be as large as it can, like long.

though long also can't fit output for very very large int. Considering that if the input is large enough that the output will not fit inside a long variable, rather than giving the wrong output, it should specify that the input is too large for this algorithm to be performed.

Also need some more test cases.

debasishbsws avatar Nov 01 '22 16:11 debasishbsws

Or we could use BigNumbers there, both options are fine IMO

siriak avatar Nov 01 '22 17:11 siriak

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Dec 02 '22 00:12 github-actions[bot]

i guess if we can store the answer in an array... example: answer of 77th fibonacci number is 5527939700884757. we can store it like {5,5,2,7,9,3,9,7,0,0,8,8,4,7,5,7} and later on print array as our answer. we remain confined to range of long data type and print appropriate message...

utkarsh-soni488 avatar Dec 06 '22 15:12 utkarsh-soni488

True is

Starkpk avatar Dec 12 '22 15:12 Starkpk

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jan 12 '23 01:01 github-actions[bot]

Please reopen this issue once you add more information and updates here. If this is not the case and you need some help, feel free to seek help from our Gitter or ping one of the reviewers. Thank you for your contributions!

github-actions[bot] avatar Jan 20 '23 00:01 github-actions[bot]