For any given number greater than 9, we would need to find the number of digits present in the number by pure logic. For this, we would use the standard divisibility rule of 10 in which when a number is divided by 10 the last digit of the number is returned as the remainder and the remaining digits are returned as the quotient. For example : 6234 divided by 10 leaves 4 as remainder since 10 divides 6234 by 623 times. We use this rule to strip the numbers and count them.

```
public static int NumberOfDigits(int n)
{
int counter = 0;
while (n > 0)
{
n = n / 10;
counter++;
}
return counter;
}
```

**How it works:**

For any given number, say 6234 the loop runs till the number is a 0.

We iteratively divide the number by 10 and assign the quotient to itself. So

```
n = 6234 / 10 = 623
n = 623 / 10 = 62
n = 62 / 10 = 6
n = 6 / 10 = 0
```

We get the counter which will be set to 4 at the end of loop.

Loops • Added 8 months ago

Compute and generate a compressed string for a given string containing repetitions

Loops
Strings

Find all possible natural numbers below a given limit such that a3+b3 = c3+d3

Loops

Find all the pairs in a given ordered set of numbers whose sum is equal to a given input sum

Loops

Find all the pairs in a given unordered set of numbers whose sum is equal to a given input sum

Loops

Sort the given unordered set of Binary digits

Loops
Sorting

Role-based Access Control in AWS - Assuming Roles and accessing via ASP.NET Core

AWS
ASP.NET Core

Top 10 LINQ methods we use in our everyday C# Development

C# Concepts

Implementing a Worker Service in ASP.NET Core

ASP.NET Core

Understanding Time Complexity and Big O notation in Algorithms

Algorithms

Creating ASP.NET Core Microservices in AWS using SAM and CloudFormation

AWS
ASP.NET Core