The professor is dabbling about with a technique known as "recursion". Now, recursion is a powerful tool and can easily solve problems that would be difficult to solve using most other techniques. But as with all powerful tools, one must be careful lest one's powerful tool turn and bite one on the butt.
In inexperienced hands, recursion can and most likely will, drop one into the dreaded "infinite loop".
https://en.wikipedia.org/wiki/Recursion
Recursion used incorrectly:
recursion def: noun -- see recursion
recursion used correctly:
unsigned int factorial(unsigned int n) { if (n == 0) { return 1; } else { return n * factorial(n - 1); } }
The professor is dabbling about with a technique known as "recursion". Now, recursion is a powerful tool and can easily solve problems that would be difficult to solve using most other techniques. But as with all powerful tools, one must be careful lest one's powerful tool turn and bite one on the butt.
ReplyDeleteIn inexperienced hands, recursion can and most likely will, drop one into the dreaded "infinite loop".
https://en.wikipedia.org/wiki/Recursion
Recursion used incorrectly:
recursion def: noun -- see recursion
recursion used correctly:
unsigned int factorial(unsigned int n) {
if (n == 0) {
return 1;
} else {
return n * factorial(n - 1);
}
}
If the witch floats it is proof of witchery, hang her!
ReplyDeleteIf the alleged witch sinks, it is proof of innocence, too bad.