In the example code on for the Credit problem, it says,

Multiply every other digit by 2, starting with the number’s second-to-last digit, and then add those products' digits together.

Moverover, the example confusingly shows

For the sake of discussion, let’s first underline every other digit, starting with the number’s second-to-last digit:


This example is poor because I'm not sure if they're starting with the bold 0 on the right, or the bold 7 on the left,

moving on...

Okay, let’s multiply each of the underlined digits by 2:

7•2 + 2•2 + 2•2 + 4•2 + 3•2 + 0•2 + 0•2

While numbers can be ambiguous it would seem award to write an addition problem where the number on the left is the "last digit".

What's the last digit, the one on the left or the right.

  • With 9 + 1, the 9 rolls over and we add add the 0 digit to the left making it sound like the last digit, having come after the ten's place.
  • We read 123, from the left to the right and the last digit sounds like it's the 3?
  • If you are asking questions about the CS50AP course, please be sure to mention that, as the problems for that course are not necessarily the same as the ones in the current CS50x course. This version of credit is not part of pset1 (as the AP course does not have psets).
    – curiouskiwi
    Jan 29, 2019 at 7:52
  • @curiouskiwi ah, I didn't realize the AP and the CS50x had different problems, I just figured the AP was more indepth, feel free to edit my questions/tags if I'm doing something wrong or it can be improved. Jan 29, 2019 at 7:55
  • We'd changed the example for the CS50x course last year, but the AP course is using a different example. We'll look at clarifying.
    – curiouskiwi
    Jan 29, 2019 at 19:49

3 Answers 3


For the sake of discussion, let’s first underline every other digit, starting with the number’s second-to-last digit:


Second to last digit is the digit before the last digit, in this case, the last 0. It is saying to start with the last 0, and work your way to the left, using every other digit.

It's done this way so that the calculation is done in the same manner, no matter if there are an even or an odd number of digits in the number.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)


Agreed that the example used can be ambiguous. We have updated the AP Credit problem spec with a better example that makes it clear that you must start from the last digit (and the first number to be multiplied by 2 is the second-to-last digit starting from the end (the right).


The wording is poor. The last digit in this context is the right-most digit.

If you're failing these tests, that's likely what is happening,

:( identifies 5105105105105100 as MASTERCARD
    expected "MASTERCARD\n", not "INVALID\n"
:( identifies 4111111111111111 as VISA
    expected "VISA\n", not "INVALID\n"
:( identifies 4012888888881881 as VISA
    expected "VISA\n", not "INVALID\n"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .