Ad
  • Custom User Avatar

    Ask yourself, if a number is divisible by x, then what is its remainder after the division ? ^^

  • Default User Avatar

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

  • Custom User Avatar

    1492952653 is not prime: 1492952653 = 31 × 48159763. The problem is with your code.

  • Custom User Avatar

    This Kata doesn't work for Python. In the random tests it returns that the number 1492952653 isn't prime. Is it a fail in the Kata or in my Code?

  • Custom User Avatar

    The problem is that with Random.Shared.Next(1, int.MaxValue), your tests have a very high chance to be mostly meaningless: they will generate many numbers which are very easy to solve, and very few interesting numbers, which are more difficult to solve. For example, out of 30 numbers you generated, approx. 15 of them will be even numbers, which are trivial to solve.

    Your tests are not great, because they do not generate interesting inputs. Your solution is apparently also not great, because it's not able to solve the interesting inputs :)

  • Custom User Avatar

    Well, I have some bad news: there seems to be ~1000 tests when you hit "Attempt".

    The problem is that your solution is doing more work than it has to. Your max condition can be improved significantly :P

  • Default User Avatar

    C#. Why does "Attempt" time out? I extended the test script to include 30 of these:

    yield return new TestCaseData(Random.Shared.Next(1, int.MaxValue)).Returns(true);

    and multiple test runs completed in, and I quote:

    Time: 4756ms Passed: 6Failed: 30Exit Code: 1

    Time: 4578ms Passed: 6Failed: 30Exit Code: 1

    Time: 6446ms Passed: 8Failed: 28Exit Code: 1

    Time: 9301ms Passed: 9Failed: 27Exit Code: 1

    Time: 8725ms Passed: 9Failed: 27Exit Code: 1

    Time: 5229ms Passed: 7Failed: 29Exit Code: 1

    yet "Attempt" constantly times out at 12s. It seems like "Attempt" runs considerablly slower than merely testing.

    I will skip this kata :(

  • Custom User Avatar

    Read about sieve of eratosthenes

  • Custom User Avatar

    What does your function return for negative numbers like -3? Read the description again. Also, printing the input would help you debug your code.

  • Custom User Avatar

    First of all, your code is almost unreadable because it's all on one line. Format it properly as shown here https://docs.codewars.com/references/markdown/#code-block

    Secondly, from description:

    a prime number is a natural number greater than 1

    Why are you bothering with negative numbers then?

    It also looks like you got some flawed logic in your else statement, but it's just a guess because, again, your code is unreadable right now.

  • Default User Avatar

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

  • Default User Avatar

    In VS it works. But here no, i can't understand

  • Custom User Avatar

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

  • Custom User Avatar

    prime is not a negative number

  • Custom User Avatar

    Your code being too slow is not a kata issue. Try using a faster algorithm. Read the Note in the description about performance btw.

  • Loading more items...