2 ms·
Dammit, I made a syntax error. The factorial function in C should be int fctl(int n){ return ( (n == 1) ? n : n * fctl(n)); }
by philwelch 17y ago
Dammit, I made a syntax error. The factorial function in C should be
int fctl(int n){ return ( (n == 1) ? n : n * fctl(n)); }
- philwelch 17y ago(n-1) for the recursive call. God, I'm failing this interview.
- Flemlord 17y agoHeh. Our actual interview question is similar but we ask them to add instead of multiply. We ask them to add up all positive whole numbers equal to or less than x. Good developers (who make it to the next round) bang out the answer in literally 30 seconds. Ok developers (who still make it to the next round) usually struggle for a while, maybe implementing it non-recursively first. The other 70% just type nonsense until I cut them off after 15 minutes. If somebody makes a mistake I tell them and give them hints until they fix it. Well... it depends on the magnitude of the mistake I suppose. If they're not even in the right ballpark I keep my mouth shut.