Question: Write a program using recursion to calculate triangular numbers (try to learn from the below Program 7.17) #include int main (void) { unsigned int j;

Write a program using recursion to calculate triangular numbers (try to learn from the below Program 7.17)

#include int main (void) { unsigned int j; unsigned long int factorial (unsigned int n); for ( j = 0; j < 11; ++j ) printf ("%2u! = %lu ", j, factorial (j)); return 0; } // Recursive function to calculate the factorial of a positive integer unsigned long int factorial (unsigned int n) { unsigned long int result; if ( n == 0 ) result = 1; else result = n * factorial (n - 1); return result; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!