Ad
  • Custom User Avatar

    I think the kata should include negative numbers too.

    Out of specs, so no. Don't arbitrarily introduce feature creep (especially if it's pointless).

    Also have you realized that everyone except you are clinging onto that definition? Maybe you haven't considered that fact that it's you who was wrong all along?

  • Custom User Avatar

    After 26,569 completions nobody is going to change the kata to do something else, the description is clear and states what you should consider a prime number and what not. Having another definition that applies to another set of numbers (integers vs natural) is pointless. Also, by your definition is p=±1 prime?

  • Custom User Avatar

    mmm I need to check my maths too, apparently... x)

  • Custom User Avatar

    I don't even know why we are discussing this when in the description it says:

    Per Wikipedia, a prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.

  • Custom User Avatar

    That's wrong though, because by that you can also argue that 5 is divisible by -5, and hence not a prime number ;-)

    The point is, when we do math related to prime numbers we only consider natural numbers, where negative numbers simply doesn't exist. It's excluded by definition.

  • Custom User Avatar

    you need to check your maths.

    Definition of a prime: "number that is only divisible by 1 and itself."
    -5 is divisible by 5 => not a prime.

  • Custom User Avatar

    It seems you didn't read the kata description:

    A prime number (or a prime) is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers.

  • Custom User Avatar

    Err, no, it's not. Try returning num > 0 and check if there is any tests that's not passing with a negative number.
    Have you read the prime number definition in the kata's description? No ambiguities there. The number passed to your function can be negative, but it won't be a prime number by definition.