Ad
  • Default User Avatar

    I think it will also no work for n = 2 .
    Because you have not reset the variable value answer = 0 inside for loop of (i).
    As a result for n = 2, i condition satisfies , j contition satisfies (Twice), for i = 2 , j = 0 answer = 1 + 3 which is equal to 4.
    which is supposed to be equal to 3. please see and check you code once again.

  • Default User Avatar

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