Question: I am trying to sum every other digit in the card number by doing this: 

```
/*
Return the sum of the odd-place digits.
*/

public static int sumOfoddPlace(long number)
{
    int maxDigitLength = 16;
    int sum = 0;
    for (int i = 1; i <= maxDigitLength; i++)
    {
        if (i % 2 == 1)
        {
            sum = sum + (int)(number % 10);
        }
        break;
    }
    return sum;
}

```

All I get is 6. The sum I am looking for is supposed to be 37.

Answer: 
Try this ... this should work for you

```
     public static int sumOfoddPlace(long number)
     {
         int maxDigitLength = 16;
         int sum = 0;
         for (int i = 0; i < maxDigitLength; i++)
         {
             if (i % 2 != 0)
             {
                 sum =  (sum + (int)(number % 10));
                 number =  number/10;

             }else {
                 number =  number/10;
            }

         }
         return sum;
 }

```

What I have done here is if `i` is odd, I take a mod of the number so I get the last digit of the number and then add it to sum and then I get rid of the last digit by dividing it with 10 and if the number is even I just get rid of the digit in the `i`th position.

Here I am collecting the digits in odd places in reverse order.
Here is updated code in which i have removed logic of flag.This is shorter and easier to understand.

```
public static int sumOfOddDigits(long number){
    int sum = 0;
    String newString = new StringBuilder(String.valueOf(number)).reverse().toString();
    number = Long.parseLong(newString);

    while (number != 0){
        sum = (int) (sum + number % 10);
        number = number / 100;
    }
    return sum;
}

```