From 0d7db91ec063770b76135dfb4bc691f1557ca548 Mon Sep 17 00:00:00 2001 From: Michele Sessa Date: Tue, 26 Sep 2023 12:11:29 +0100 Subject: [PATCH] docs(luhn-algorithm): clarify input handling and steps in the example --- subjects/luhn_algorithm/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/subjects/luhn_algorithm/README.md b/subjects/luhn_algorithm/README.md index 518d672b..47a9289c 100644 --- a/subjects/luhn_algorithm/README.md +++ b/subjects/luhn_algorithm/README.md @@ -5,8 +5,9 @@ Create a function which checks if a number is valid per the Luhn formula. The function will receive a string and return a boolean. -An empty string or a number with only one digit will be considered an invalid number. -Spaces are accepted in the script but have to be stripped during the calculation (in other words they won't affect the result). + +**Invalid inputs:** An empty string or a number with only one digit are considered invalid. +**Handling spaces:** Spaces are accepted but have to be ignored during the calculation (in other words they won't affect the result). The Luhn formula is used to check if a number is a valid credit card number and in some other scenarios where you need to check a number fast and without accessing a database. @@ -23,7 +24,7 @@ So we will get: - `4539 3195 0343 6467` - `4_3_ 3_9_ 0_4_ 6_6_`: numbers to modify -- `8_6_ 6_9_ 0_8_ 3_3_`: modified numbers +- `8_6_ 6_9_ 0_8_ 3_3_`: modified numbers (for numbers over 9 we subtracted 9 already) - `8569 6195 0383 3437`: the new sequence of digits - `80`: the sum of all digits - `80` is evenly divisible by 10 so the result is `true`