Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Op solved it, closing
You see how
m
is defined as along
in the arguments instead ofint
?.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 along
and your solution works.@CrazyMerlyn: thanks for your help!
@jamesjohnson92: maybe you could avoid the use of factorial.
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.
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)?