Recursive Factorial method.
using System; public class FactorialTest { public static void Main( string[] args ) { for ( long counter = 0; counter <= 10; counter++ ) Console.WriteLine( "{0}! = {1}", counter, Factorial( counter ) ); } public static long Factorial( long number ) { if ( number <= 1 ) return 1; else return number * Factorial( number - 1 ); } }
1. | Recursive sum method | ||
2. | Use a recursive method, travel, to journey from start to finish | ||
3. | Recursive function in action | ||
4. | Define function | ||
5. | Catch StackOverflowException for recursive function |