1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-06-27 11:08:45 +02:00

Explicitly non-digit characters in testing exercise (#2723)

Students sometimes ask about this so I figure it'd be good to specify in
the text.
This commit is contained in:
Nicole L
2025-04-25 03:42:12 -07:00
committed by GitHub
parent 3beda3678b
commit 3474c07c13

View File

@ -8,7 +8,8 @@ The [Luhn algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm) is used to
validate credit card numbers. The algorithm takes a string as input and does the
following to validate the credit card number:
- Ignore all spaces. Reject numbers with fewer than two digits.
- Ignore all spaces. Reject numbers with fewer than two digits. Reject letters
and other non-digit characters.
- Moving from **right to left**, double every second digit: for the number
`1234`, we double `3` and `1`. For the number `98765`, we double `6` and `8`.