Ad
  • Custom User Avatar

    Op solved it, closing

  • Custom User Avatar

    You see how m is defined as a long in the arguments instead of int?.
    It's because int is too small for some of the bigger factorials.
    Your fac variable overflows and gives incorrect results in those cases. Make it a long and your solution works.

  • Custom User Avatar

    @CrazyMerlyn: thanks for your help!
    @jamesjohnson92: maybe you could avoid the use of factorial.

  • Custom User Avatar

    It is failing because you keep appending to the same factoial list.
    When you check your code separately, you probably just use the function once.
    But when you use the function again(like repeated tests), it appends two more 1s in the list for each call.
    This ruins your list, and by extension, your code.

    If you plan on calling the generatelist again and again, it should create a new list and return it.
    On the other hand, if you want a global list you should either fill it only once, or make sure you don't make repetitions.

  • Custom User Avatar

    Based on that Test, I assume you are using Python or Ruby.
    I tried both and it seems to be working for me.

    Could you post your solution(mark it as spoiler)?