"Stack Overflow" error when checking for prime numbers
Solution 1:
You've written your program such that to test each additional possible factor, you make a recursive call. This (potentially) requires a stack frame, so will quickly run out of stack space if it needs to check many factors.
Most compilers these days will do tail call optimization, so make sure you have optimization turned on (-O or /O depending on the compiler) and it may work. However, there is no guarantee that tail-call optimization will be done, so you can't reliably write heavily recursive code like this in C safely. You need to use a loop instead.
Solution 2:
The number is 23479823. The function will call itself more than 11 million times. Every call will need another stack frame. How much it will be depends on the implementation, optimization etc but it will be more than 24MB. Stack is much smaller on Windows (I do not remember now exactly - but I think is about 1MB.). Because you need much more - you overflow it
You can lucky of course if the compiler will optimize the recursion out - but as you see it does not happen in your case.