hey.i'm new with C++ and trying to start with simple coding. here's the problem. there's no error in my code but keeps getting a failed result and couldnt figure out why.here's some code i made.
it suppose to give me
reduceDigits(173) == 2 where 1x7x3=21 and 2x1 =2 (giving the least output)
could anyone point out where i made mistake in this code?Code:unsigned int reduceDigits (unsigned int number) { int digit = 0; int product = 1; if (number != 0){ digit = number % 10; product *= digit; number = number / 10; } else{ if (product > 9){ reduceDigits (product); } else{ cout << product; } } return number; }
thanks heaps.