problem_40.java
private static int calculateDigitsBefore(int num) {
    if(num == 1)  return 0;

    int length = String.valueOf(num).length();
    int digitsBefore = (9 * (int) Math.pow(10, length-2)) * (length-1);

    return digitsBefore;
  }
//Method to get the number of digits before 'num', where 'num' is a power of 10:
Method to get the number of digits before 'num', where 'num' is a power of 10.
Method to get the number of digits before ' num ' where ' num ' is a power of 10 .
private static int calculateDigitsBefore(int num) {
    if(num == 1)  return 0;
    int length = String.valueOf(num).length();
    int digitsBefore = (9 * (int) Math.pow(10, length-2)) * (length-1);
    return digitsBefore;
  }
private static int calculateDigitsBefore ( int num ) { if ( num == 1 ) return 0 ; int length = String . valueOf ( num ) . length ( ) ; int digitsBefore = ( 9 * ( int ) Math . pow ( 10 , length - 2 ) ) * ( length - 1 ) ; return digitsBefore ; }
Method to get the number of digits before 'num', where 'num' is a power of 10:
Method to get the number of digits before ' num ' where ' num ' is a power of 10 :