Ad
  • Default User Avatar

    You accidentally edited the edge cases to have a space.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This solution does not work anymore due to comparing a float with an integer of large size.
    You can avoid this by removing the division on the left side and multiplying the right side by 4 instead.

  • Default User Avatar

    You are trying to write to a variable outside the scope of your function with p0 += something.
    (It's bad practice to use functions to edit variables outside of your function to begin with most of the time)

    By declaring pop you have a variable you can write to and do what you want with inside your function.

  • Default User Avatar

    Nevermind what I said

  • Default User Avatar

    Why the +0.005 to my final answer you ask?
    The answer: floating point arithmetic sucks, it's a work-around for rounding errors.
    Unfortunately I do not know of any way to get rid of this, if anyone can fork this and provide a proper answer that would be nice.

    And yes for the series f(x) = a * f(x-1) + b the general solution for x finding value Q:
    log_a((Q+b/(a-1))/(f(0)+b/(a-1))) Maths baby