_Spongey's blog

By _Spongey, history, 5 months ago, In English

So, My approach was to find the first two numbers they are fibbonachi like for example 6, 8, 14, 22 let's call the first number n, and the second n... then the sequence is: n, m, n+m, n+2m...

My code 238882947 So I basically found the sequence of ns and ms k'th index (K is the length of the sequence given) and made a for loop to get every possible number that works for this solution it worked right for most test cases (In test#1 lol) and printed out the correct first and second numbers of the sequence

  • Vote: I like it
  • +3
  • Vote: I do not like it

»
5 months ago, # |
  Vote: I like it +3 Vote: I do not like it

As Mentionned in the diagnosis u have an integer overflow problem .Integers in C++ have bounds (2 to the power of 31 -1) and the fibonacci sequence increases exponentially.

  • »
    »
    5 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    My bad, I saw that my answer was wrong on my ide... How do I fix this issue btw?

    • »
      »
      »
      5 months ago, # ^ |
        Vote: I like it +6 Vote: I do not like it

      U can long long in C++ so u get a bigger bound of integers (2 to the power of 63 -1) but it won't fix the issue as the fibonnaci sequence grow exponentially .Also the problems tells u to create a new fibonnaci sequence by fixing the first and second element but in ur code u assumed they are one

»
5 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Solved it, 239474314