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.