johnmarkthegreat

Sample 1 for Recursive Function

Mar 5th, 2024
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.15 KB | Source Code | 0 0
  1. #include <stdio.h>
  2.  
  3. int factorial(int n);
  4.  
  5. int factorial(int n) {
  6. if (n <= 1) {
  7. return 1;
  8. }
  9. else {
  10. return n * factorial(n - 1);
  11. }
  12. }
Tags: CSIT 122
Advertisement
Add Comment
Please, Sign In to add comment