Unformatted text preview: } else // If the integer is less than zero, entry is not valid. { cout << "Not a valid integer.\n"; } } return 0; } // Recursive function that calculates factorial. long factorial(long n) { long fact; // Local variable returned by function. if(n > 1) { // If n is not one, make another recursive call. fact = n * factorial(n  1); } else { // Exit condition fact = 1; // If n is one, recursion stops and flow of logic } // begins "backing out" of recursive calls. return(fact); // Return fact to the next level of recursion. }...
View
Full Document
 Spring '11
 Dr.AnoopSarkar
 Recursion, long factorial

Click to edit the document details