Code Monkey home page Code Monkey logo

Comments (8)

sachinarora707 avatar sachinarora707 commented on May 5, 2024

Hi @naveenyadav15 Can you be more specific with the issue?? It's working fine for me and giving a correct output. Fibonacci sequence is defined in 2 ways. One starts with 0 and 1. Other starts with 1 and 1.
Both these sequences are correct. If this resolves the issue, please check.

from c-plus-plus.

naveenyadav15 avatar naveenyadav15 commented on May 5, 2024

Like, if your input is 50 it is giving wrong answer(negative)

from c-plus-plus.

sachinarora707 avatar sachinarora707 commented on May 5, 2024

@naveenyadav15 i checked the code again. The problem is that the number at 48 is greater than the upper limit of a signed int, i.e., 2,147,483,647. So, the code breaks at the input greater than 47.

from c-plus-plus.

naveenyadav15 avatar naveenyadav15 commented on May 5, 2024

Okay, then we can correct it by using long long.

from c-plus-plus.

Ankit-Dhankhar avatar Ankit-Dhankhar commented on May 5, 2024

For larger number we can implement it with different data structure so that there would be no problem with size of data-type. @sachinarora707 if required I can work on that.

from c-plus-plus.

sachinarora707 avatar sachinarora707 commented on May 5, 2024

@naveenyadav15 Using unsigned long long int would improve it. But, it would still not work for very big numbers. For higher inputs, the code will break again.

from c-plus-plus.

sachinarora707 avatar sachinarora707 commented on May 5, 2024

@Balance-Breaker Sure, work on the issue.

from c-plus-plus.

christianbender avatar christianbender commented on May 5, 2024

I fixed the issue. I changed the datatype from int to long long.
This datatype can be overflow, too. But we increase the max limit.

from c-plus-plus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.