Factorial of a number is calculated by multiplying all the numbers from 1 till the number itself. For any given input number, we are required to calculate factorial, using recursion. Recursion is a technique in which a method calls itself in a loop until some breaking statement is met. This technique makes programming significantly simple and is used in complex computations to save memory.

```
public static double ComputeFactorial(int n)
{
if (n >= 1)
{
var compute = n * ComputeFactorial(n - 1);
return compute;
}
else
return 1;
}
```

**How it works:**

Assume we're passing a number 5 to the function, it then checks if the number is not less than 1. Since 5 isn't less than 1, the method returns product of the number passed (in this case 5) along with a call to itself passing number decreased by 1. And this continues till the number becomes 0, which is a breaker and then the total computation is returned.

```
******* Factorial Recursion *******
Enter input:5
1 calling out on 0 returns 1
2 calling out on 1 returns 2
3 calling out on 2 returns 6
4 calling out on 3 returns 24
5 calling out on 4 returns 120
5! = 120
```

Find the number of occurrences of a given character in a string

Strings
Loops

Find the reverse of given number

Loops

Find the Factorial of a given number using Recursion

Recursion
Loops

Check if a given string is Palindrome

Strings
Loops

Find if the given number is a Perfect Number

Special Numbers
Loops

Subscribe to my newsletter and get the first copy of every new post delivered straight into your inbox.

Externalizing Configurations to AWS SSM Parameter Store and using in ASP.NET Core API

AWS
ASP.NET Core

Working with Options pattern in ASP.NET Core - The Complete Guide

ASP.NET Core

Creating AWS Lambda Layers in ASP.NET Core - Getting started

AWS
ASP.NET Core

Deploying Express.js API to AWS Lambda and API Gateway

NodeJS
Express
MySql
AWS

Securing ASP.NET Core APIs with IdentityServer4 - Getting Started

ASP.NET Core
IdentityServer4