does anyone know of a Math method that returns the largest number of a given number of digits.
e.g The largest number using 1 digit is 9, 2 is 99, 3 is 999, 4 is 9999 .... and so on.
It is easily achievable using strings however this is not quite what I am looking for.
private double GetLargestNumber(int numOfDigits)
{
string max = "";
for (int i = 1; i <= numOfDigits; i++)
{
max += "9";
}
return Convert.ToDouble(max);
}
Thanks in advance.
return Math.Pow(10, numOfDigits) - 1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With