I actually try to do the Credit Task back from pset1. So far i understand how the calculation for the checksum validation of the Credit Card Number works, and could do it on Paper.

The Problem, i have no clue of how even start with in the first place yet, is that i don´t know how to adress single numbers in an int to multiply ever 2nd Number and so on. I literally know the Plan but lack the tool to start with it right now.

Any advice would be highly appreciated.

2 Answers 2


You could take the number as a string, and access the individual digits as characters (subtract '0' or 48 to obtain their value), or parse the number as a long long int and use for example / and % in a loop to obtain the various digits (% 10 would obtain the last digit, while integer division truncates the result of a division).

Ensure you don't change variables you need later, use a copy in that case (for example, function parameters are passed as copies by default).


You need to play around with the modulus operator for a bit. I don't want to give away too much, but when I did it, I used the truncation of the operator to my advantage ;)

You must log in to answer this question.

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