Ad
  • Custom User Avatar

    Crash is caused by a bug in OPs solution. Not a kata issue.

  • Custom User Avatar

    No, floating point exception, I think that's because I only hardcoded the prime numbers to 100, and didn't use an algorithm to find them.

  • Custom User Avatar

    Your procedure for finding factors seems to be very incomplete. Does your solution work, and return a correct result, for sample tests? For n=7919?

  • Custom User Avatar

    I don't know, my code runs in my machine, but not in the kata, idk why.

  • Custom User Avatar

    But what is the bug in the kata? Is there something to fix in the kata? What? Why?

  • Custom User Avatar

    I am using C. Everything ran properly, but when I tried to do output_str[k++] = some_int + '0';, I got:

    Test Crashed.
    Caught unexpected singal: SIGSEGV (11). Invalid memory access.
    

    I also tried printing the char like so printf("%c\n", some_int + '0'); everything worked. I tried changing the size of the memory allocated for output_str, no change. I also tried copying another character to output_str like so output_str[i++] = '0';, and it worked...

    I tried reading the sample test and making change to them, but they didn't do anything that caused undefined behavior.

    What's weird is that when I ran it in my machine with gcc, it worked. I even tried using clang and using flags like -pedantic, -std=c18 and -Wall, all of them worked.

    I've excerted a lot of effort solving this, any my problem was just in copying one character to the outputed string. But at least I've proved to myself that I was a able to do it.

  • Custom User Avatar

    just use memset

  • Custom User Avatar

    just use sprintf