Ad
  • Custom User Avatar

    Your solution is timing out because the loop for checking divisibility is inefficient for large numbers. By looping up to num / 3, you are performing far more checks than necessary, especially for large inputs, which causes performance issues and exceeds Codewars time limits. This is likely why your submission fails with a timeout error. You need to research a more efficient way to determine if a number is prime.

    -- 🤖

    It is not the servers.

  • Custom User Avatar

    Misread instructions, forgot that negatives are arbitrarily not considered prime, and was using Math.abs to simplify things.
    Edited to new issue. Language is JS.

  • Custom User Avatar

    you must be misreading the logs

    running your javascript code without the line that hardcodes for 5, the error message is

    5 is prime: expected false to equal true

    so, your code is wrong regardless

  • Custom User Avatar

    You tell us what language you are trying and show us your code, so we can reproduce your error and see what you are getting wrong.

  • Custom User Avatar

    Instructions say looping up to n/2 would be too slow, I've gotten my algorithm down to roughly n/6 but still timing out at 12000 ms. Is this a problem with my code or with the servers?

  • Custom User Avatar

    C#, then i run the test button it tests 0, 1, and 2. they all pass on test. So i went to run the attempt, the last 3 test numbers are 0, 1, 2 and they fail with no code changes.

  • Custom User Avatar

    Where? How? In what language? What is your code?

  • Custom User Avatar

    descriptions says positve numbers can only be prime, but "answers" differ.
    numbers in test and attepmt ACT DIFFERENTLY

  • Custom User Avatar

    There is a specific note about performance in the description. So, you should not complain about something that was explicitly given to you upfront and you still decided to solve the kata anyway.

  • Custom User Avatar

    I didn't really like this Kata. If there had been a realy large number in the sample test as well and not only in the hidden/submit test it would have been fine.
    The real challenge is not to check for prime numbers, it is to check for prime nubers in a efficient way without running in a timeout on codewars.

  • Custom User Avatar
  • Custom User Avatar

    Your code must me too slow if it doesn't pass. And we don't read minds, so if you want help with your code, you should show it to us. Follow this guide: https://docs.codewars.com/training/troubleshooting#post-discourse

  • Custom User Avatar

    Do you know what that'd be? I tried a few.

    Not doing this one for a while.

  • Custom User Avatar

    Ridicilous this fails because it took like a second lol. Everything else passed.

  • Custom User Avatar

    No, you can't submit unless you pass all the tests in the alotted time. You need a faster algorithm.

  • Loading more items...