0

NOTE : I AM USING STRING INSTEAD OF LONG LONG TO STORE CC.

enter image description here enter image description here enter image description here

enter image description here

:) credit.c exists

:) credit.c compiles

:) identifies 378282246310005 as AMEX

:) identifies 371449635398431 as AMEX

:) identifies 5555555555554444 as MASTERCARD

:( identifies 5105105105105100 as MASTERCARD \ expected output, but not "Retry:\n"

:( identifies 4111111111111111 as VISA \ expected output, but not "Retry:\n"

:( identifies 4012888888881881 as VISA \ expected output, but not "Retry:\n"

:( identifies 1234567890 as INVALID \ expected output, but not "Retry:\n"

:( rejects a non-numeric input of "foo" \ expected prompt for input, not exit code of 0

:( rejects a non-numeric input of "" \ expected prompt for input, not exit code of 0

https://sandbox.cs50.net/checks/6c271d406e8f4ceabd15647a6d55e472

Why is 5105105105105100 a MC ? Its invalid based on the algorithm : 25%10 is not equal TO ZERO SO WHY ITS LISTED AS mASTERCARD ?

4111111111111111 is listed as VISA. But 27%10 is not equal to ZERO so it should invalid and not a VISA.

Either I misunderstood the algorithm or these paypal sample are wrongly listing some of these credit card numbers as valid. PLEASE HELP !

0

1 Answer 1

0

Take the number, and starting from the right, double every second digit. If the double has two digits, add them, creating an odd digit. Now add those resulting digits. Makes 20 and 30 for your Mastercard and VISA examples.

2
  • Wow...what a silly mistake. Thankyou Blauelf, u r a lifesaver.
    – ravi s
    Commented Mar 30, 2017 at 5:17
  • thanks!! this work for me too! Commented Jan 29, 2018 at 20:39

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