You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/luhn/instructions.md
+8-12Lines changed: 8 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -14,25 +14,23 @@ All other non-digit characters are disallowed.
14
14
15
15
### Valid credit card number
16
16
17
-
```text
18
-
4539 3195 0343 6467
19
-
```
17
+
The number to be checked is `4539 3195 0343 6467`.
20
18
21
-
The first step of the Luhn algorithm is to double every second digit, starting from the rightmost (last) digit of the number and moving left.
19
+
The first step of the Luhn algorithm is to start at the end of the number and double every second digit, beginning with the second digit from the right and moving left.
22
20
23
21
```text
24
22
4539 3195 0343 6467
25
23
↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ (double these)
26
24
```
27
25
28
-
If the result of doubling a digit is greater than 9, subtract 9 from that result.
26
+
If the result of doubling a digit is greater than 9, we subtract 9 from that result.
29
27
We end up with:
30
28
31
29
```text
32
30
8569 6195 0383 3437
33
31
```
34
32
35
-
Then sum all digits, and if the sum is evenly divisible by 10, the original number is valid.
33
+
Finally, we sum all digits, and if the sum is evenly divisible by 10, the original number is valid.
0 commit comments