Ad
  • Custom User Avatar

    Lol, seriously? This isn't enough for you?

    This problem requires you to define an extended version of the factorial function, one that accepts all integers! For nonnegative integers, your function should behave as above. For n<0,

    factorial(n) = (n)(n+1)...(-2)(-1).

    For example, factorial(-1) = -1, factorial(-2) = 2, factorial(-3) = -6.

    That's about as explicit a definition as you can have without giving away the recursion solution. Also, five years later and I still need to explain this is a simple recursion exercise, not an innovative mathematical exploration. What is up with the people on this site.. it's bizarre. The last comment on the discourse below by @xcthulhu is like the most insane "I'm smarter than you" pissing contest comment I've ever read.

  • Custom User Avatar

    Updated to include Eq in the deriving clause, thanks.

  • Custom User Avatar

    Sorry about that. Reviewed and merged, thanks!

  • Custom User Avatar

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

  • Custom User Avatar

    Sorry, I should have reviewed this more thoroughly. I'm aiming for a fairly easy kyu level here. Would you mind editing your translation so that users are only tested against a finite list of integers?

  • Custom User Avatar

    Thanks!

  • Custom User Avatar
  • Custom User Avatar

    Sorry about that! Haven't been on in a while. Approved.

  • Custom User Avatar

    Yeah this was due to hidden tab characters, fixed now.

  • Custom User Avatar

    Fixed... for some reason they don't have vim on the kata creation text boxes, throws me off.. wish they would just default to spaces when you hit TAB.

  • Custom User Avatar

    Damn, this still isn't fixed. It's been 4 months, please just give a simple update with those 2 lines above! They work for the examples, but obviously end users cannot add them to the real tests.

  • Custom User Avatar

    I like this kata but the description needs improvement. I also failed on last test because of this requirement: "And don't forget about nested functions. You shouldn't handle them." This needs more explanation..

  • Custom User Avatar

    When I say function, I am referring to the mathematical definition of a function. It is a mapping of elements to elements. This is a 6kyu dude, and I wrote it as a 7kyu. It is a simple recursion exercise; I am not requiring people to have efficient solutions.

  • Custom User Avatar

    What's up with you guys... I already explain that the factorial function we know and love is defined only for nonnegative integers. And you are incorrect - this function, as I define it, is defined for all integers. Obviously your JS solution will not be able to evaluate it for all integers due to physical memory and time restrictions, but mathematically it's defined for all integers.

    You and xcthulhu are really missing the point here. This is the "non-discriminate factorial", and you don't even need to know about the conventional factorial function to define it. This is a contrived piecewise function that IS well defined (by the mathematical definition, maybe not yours or xcthulhu's). Each integer x in the domain of all integers is mapped to a single value in the integers.

  • Custom User Avatar

    http://www.nntdm.net/papers/nntdm-19/NNTDM-19-2-30_42.pdf Section 3.1.

    A mathematical exploration does not have to solve a problem. It can be done for the sake of the exploration. If everyone had the former view, we would not be where we are today in many fields, such as number theory providing the basis of all internet security.

  • Loading more items...