Having a little trouble with my HailstoneOdds function in my Hailstone program. It gets the count correct when I run a odd number through it because the one returned in the base case accounts for that odd number. If I enter an even number that 1 still accounts for that number even though it is not odd, therefore my count is off by 1 when the number the hailstone sequence begins with is even. Here's my code.
1 2 3 4 5 6 7 8 9 10
int HailstoneOdds(int n){
if (n == 1)
return 1;
if (Hailstone(n) % 2 == 0){
return HailstoneOdds(Hailstone(n));
}
else{
return HailstoneOdds(Hailstone(n)) + 1;
}
}