I am currently working on a project for college, first year computing class. With that being said, I am not asking for the answer, but I am asking more for some advice. In order to begin the project, I have decided to create a function called collatzSequencer that takes one argument type int.
Here is my function prototype:
int collatzSequencer(int);
Here is my function definition:
int collatzSequencer(int n) {
int stepCounter = 0;
if (n % 2 == 0) {
stepCounter += 1;
collatzSequencer(n / 2);
}
else if (n % 2 == 1) {
stepCounter += 1;
collatzSequencer((3 * n) + 1);
}
else if (n == 1) {
printf("%d\n", n);
printf("%d\n", stepCounter);
return 0;
Here is where I call the function within my main function:
int main(int argc, char* argv[]) {
int num = 5;
collatzSequencer(num);
return 0;
}
When I run my program, nothing happens and I exit with code 0. I have tried debugging my program, and I see that for some reason my IDE doesn't even run the collatzSequencer function when it is called. Although I am a beginner, I feel like I have enough knowledge to be able to find problems within only 48 lines of code, however I cannot find the issue here. Anyone have any ideas?