Yes it works, as long as your list is short.
If the list can be longer than your integer precision, you should use big integers and I think this is overkill: there are situations in which recursion is useless and more time consuming than an iterative algorithm (I'm thinking of the classical book example of calculating n!) but in others it can be the fastest/cleanest approach
Rule One: Do not act incautiously when confronting a little bald wrinkly smiling man.
In reply to Re^2: Recursion problem
by psini
in thread Recursion problem
by someone202
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |