Skip to content

Commit 4b3b51e

Browse files
committed
change second example
1 parent 5d56d92 commit 4b3b51e

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

exercises/luhn/instructions.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ All other non-digit characters are disallowed.
1717
```
1818

1919
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.
20-
We will be doubling:
2120

2221
```text
2322
4539 3195 0343 6467
@@ -39,25 +38,32 @@ Then sum all digits, and if the sum is evenly divisible by 10, the original numb
3938

4039
80 is evenly divisible by 10, so number `4539 3195 0343 6467` is valid!
4140

42-
### Example 2: invalid credit card number
41+
### Example 2: invalid Canadian SIN
4342

4443
```text
45-
8273 1232 7352 0569
44+
066 123 468
4645
```
4746

48-
Double every second digit, and subtract 9 if the doubled digit exceeds 9.
47+
Double every second digit starting from the rightmost (last) digit of the number and moving left.
48+
49+
```text
50+
066 123 478
51+
↑ ↑ ↑ ↑ (double these)
52+
```
53+
54+
If the result of doubling a digit is greater than 9, subtract 9 from that result.
4955
We end up with:
5056

5157
```text
52-
7253 2262 5312 0539
58+
036 226 458
5359
```
5460

5561
Sum the digits:
5662

5763
```text
58-
7 + 2 + 5 + 3 + 2 + 2 + 6 + 2 + 5 + 3 + 1 + 2 + 0 + 5 + 3 + 9 = 57
64+
0 + 3 + 6 + 2 + 2 + 6 + 4 + 5 + 8 = 36
5965
```
6066

61-
57 is not evenly divisible by 10, so number `8273 1232 7352 0569` is not valid!
67+
36 is not evenly divisible by 10, so number `066 123 478` is not valid!
6268

6369
[luhn]: https://en.wikipedia.org/wiki/Luhn_algorithm

0 commit comments

Comments
 (0)