C examples for Function:Utility Function
Calculating Factorials Recursively
#include <stdio.h> long int factorial (int n); int main (void) { for (int j = 0; j < 11; ++j ) printf( "%2u! = %lu\n", j, factorial (j)); return 0;/*from w w w .j a va 2 s . c om*/ } //Recursive function to calculate the factorial of a positive integer. long int factorial (int n){ long int result; if ( n == 0) result = 1; else result = n * factorial (n - 1); return result; }