0

I am supposed to find if cc numbers are valid based on these rules:

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

Add the sum to the sum of the digits that weren’t multiplied by 2.

If the total’s last digit is 0 (or, put more formally, if the total modulo 10 is congruent to 0), the number is valid!

When I work-it-out by hand, I dont get valid for these numbers... but they are (from the solutions site). Can I see how its done correctly?

371449635398431

5105105105105100

4111111111111111

4012888888881881

Thanks,

1 Answer 1

1

Taking the first one through the example in the spec:

3 7 1 4 4 9 6 3 5 3 9 8 4 3 1

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

7*2 + 4*2 + 9*2 + 3*2 + 3*2 + 8*2 + 3*2

That gives us:

14 + 8 + 18 + 6 + 6 + 16 + 6

Now let’s add those products' digits (i.e., not the products themselves) together:

1 + 4 + 8 + 1 + 8 + 6 + 6 + 1 + 6 + 6 = 47

Now let’s add that sum (47) to the sum of the digits that weren’t multiplied by 2:

47 + 3 + 1 + 4 + 6 + 5 + 9 + 4 + 1 = 80

If the total’s last digit is 0 (or, put more formally, if the total modulo 10 is congruent to 0), the number is valid!

Now you try it :)

0

You must log in to answer this question.

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