1

when i try to check pset1/credit i get these errors:

identifies 369421438430814 as INVALID expected "INVALID\n", not "AMEX\n"

try to check it according Luhn's algorithm:

Checking [369421438430814]

  3   6   9   4   2   1   4   3   8   4   3   0   8   1   4  
 x1  x2  x1  x2  x1  x2  x1  x2  x1  x2  x1  x2  x1  x2  x1  
 --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  
  3  12   9   8   2   2   4   6   8   8   3   0   8   2   4  
  3 + 3 + 9 + 8 + 2 + 2 + 4 + 6 + 8 + 8 + 3 + 0 + 8 + 2 + 4  = 70

70 ≡ 0 (mod 10)

The test PASSED since the result is zero.

and the same second error, please, help me figure out. https://cs50.me/checks/f1ac2ca05b9d1e42a21d8d8760d0a1e565e16682

3

From the spec:

American Express numbers all start with 34 or 37;

This example starts with 36, and thus is invalid. The second error is similar. Review the spec for how to identify a Master Card.

You must log in to answer this question.

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