Using Recursion we can solve the bigger problem after dividing bigger problem in smaller problem.

Q1. Factorial of number n.

1 /*
2  * This program is about factorial of n number
3  * e.g n! = n * (n-1) * (n-2) *.....*1
4  * 4! = 4 * 3 * 2 * 1 = 24
5  */
6 #include <stdio.h>
7 #include <stdlib.h>
8
9 int factorial(unsigned int n)
10 {
11         /* we know factorial of 0 is 1
12          * 0! = 1
13          */
14         if (n == 0)
15                 return 1;
16         return n * factorial(n - 1);
17 }
18
19 int main()
20 {
21         unsigned int n;
22         printf("Enter the number :");
23         scanf("%d", &n);
24         if ( n < 0) {
25                 printf("Factorial of negative no not possible.\n");
26                 return -1;
27         }
28         printf("Factorial of number =%d! is %d\n", n, factorial(n));
29         return 0;
30 }

Q2. Fibonacci Series.

1 /*
2  * This program is about to find nth fibonacci no
3  * e.g fibonacci series : 0, 1, 1, 2, 3, 5, 8, .........
4  * 0th fibonaci no. = 0
5  * 1st fibonaci no. = 1
6  * 2nd fibonaci no. = 1
7  * 3rd fibonaci no. = 2
8  * etc.
9  */
10 #include <stdio.h>
11 #include <stdlib.h>
12
13
14 int fib(int n)
15 {
16         if (n == 0)
17                 return 0;
18         if (n == 1)
19                 return 1;
20         return fib(n-1) + fib(n-2);
21 }
22
23 int main()
24 {
25         int n;
26         printf("Enter the position :");
27         scanf("%d",&n);
28         printf("%dth fibonacci number in fibonacci series is %d\n",n, fib(n));
29         return 0;
30 }