7/7/2014 C program to Calculate Factorial of a Number Using Recursion
Home C Programming C++ Python
C program to Calculate Factorial of a Number Using
Recursion
This program takes a positive integer from user and calculates the factorial of that number. Instead
of loops to calculate factorial, this program uses recursive function to calculate the factorial of a
number.
Connect With Us
Source Code to Calculate Factorial Using Recursion
Facebook
/* Source code to find factorial of a number. */
Twitter
#include<stdio.h>
int factorial(int n);
Google+ int main()
{
int n;
printf("Enter an positive integer: ");
NET Programming scanf("%d",&n);
printf("Factorial of %d = %ld", n, factorial(n));
Programming Training Courses return 0;
}
Source Code Editor int factorial(int n)
{
HTML5 Programming
if(n!=1)
return n*factorial(n-1);
HTML Source Code
}
Download Source Code
ads Output
Enter an positive integer: 6
Factorial of 6 = 720
Game Development Learn C Programming
C Programming Examples C Programming To Calculate
C Programming Tutor Graphic Design
Basic C Programming Web Programming
Application Development Online Computer Programming
Data Structures In C Courses
C Language Software
ads
Similar Examples
C Program to Find Factorial of a Number
C program to Calculate the Power of a Number Using Recursion
C Program to Find Size of int, float, double and char of Your System
http://www.programiz.com/c-programming/examples/factorial-recursion 1/2
7/7/2014 C program to Calculate Factorial of a Number Using Recursion
C program to Calculate the Power of a Number
C Program to Check Whether a Number is Positive or Negative or Zero.
C Program to Count Number of Digits of an Integer
C Program to Display its own Source Code as Output
C Program to Calculate Sum of Natural Numbers
About Us | Contact Us | Articles | Advertise With Us
Copyright by Programiz | All rights reserved | Privacy Policy
http://www.programiz.com/c-programming/examples/factorial-recursion 2/2