Skip to main content
11 events
when toggle format what by license comment
Mar 14, 2020 at 2:14 comment added chux ... and at other times, recursion is the best solution. Use the right tool for the job. Typical iterations are not a good recursion solution but do allow learners to "wrap their heads around it"
Mar 13, 2020 at 22:15 answer added chux timeline score: 1
Mar 13, 2020 at 0:24 vote accept Duarte Arribas
Mar 12, 2020 at 14:31 answer added ilkhd2 timeline score: 2
Mar 12, 2020 at 9:41 answer added Lundin timeline score: 2
Mar 12, 2020 at 7:52 comment added slepic I can understand that you decided to implement it recursively as you said to be learning recursion. But if you should take a lesson from this, it should be that recursion is often not the best solution. The way you implemented it can produce up to 10 stack frames (for 32bit integers) where you only realy need one frame, two local variables and a while loop.
Mar 11, 2020 at 22:43 comment added Null Then you should check for a negative number before you call countDigits() with a negative number. Also, unsigned int may be a more appropriate argument and return type if countDigits() is not intended to count the number of digits of a negative number. It's not difficult to make it work with negative numbers, though...
Mar 11, 2020 at 22:37 comment added Duarte Arribas Didn't make it to work for them
Mar 11, 2020 at 22:37 comment added Null What about negative numbers?
Mar 11, 2020 at 22:05 review First posts
Mar 11, 2020 at 22:37
Mar 11, 2020 at 22:05 history asked Duarte Arribas CC BY-SA 4.0