Skip to content

Commit a6abc8e

Browse files
authored
Sync docs for practice exercise luhn (exercism#2458)
1 parent aa05c50 commit a6abc8e

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

exercises/practice/luhn/.docs/instructions.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,31 @@
22

33
Given a number determine whether or not it is valid per the Luhn formula.
44

5-
The [Luhn algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm) is
6-
a simple checksum formula used to validate a variety of identification
7-
numbers, such as credit card numbers and Canadian Social Insurance
8-
Numbers.
5+
The [Luhn algorithm][luhn] is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers and Canadian Social Insurance Numbers.
96

107
The task is to check if a given string is valid.
118

12-
Validating a Number
13-
------
9+
## Validating a Number
1410

15-
Strings of length 1 or less are not valid. Spaces are allowed in the input,
16-
but they should be stripped before checking. All other non-digit characters
17-
are disallowed.
11+
Strings of length 1 or less are not valid.
12+
Spaces are allowed in the input, but they should be stripped before checking.
13+
All other non-digit characters are disallowed.
1814

19-
## Example 1: valid credit card number
15+
### Example 1: valid credit card number
2016

2117
```text
2218
4539 3195 0343 6467
2319
```
2420

25-
The first step of the Luhn algorithm is to double every second digit,
26-
starting from the right. We will be doubling
21+
The first step of the Luhn algorithm is to double every second digit, starting from the right.
22+
We will be doubling
2723

2824
```text
2925
4_3_ 3_9_ 0_4_ 6_6_
3026
```
3127

32-
If doubling the number results in a number greater than 9 then subtract 9
33-
from the product. The results of our doubling:
28+
If doubling the number results in a number greater than 9 then subtract 9 from the product.
29+
The results of our doubling:
3430

3531
```text
3632
8569 6195 0383 3437
@@ -42,9 +38,10 @@ Then sum all of the digits:
4238
8+5+6+9+6+1+9+5+0+3+8+3+3+4+3+7 = 80
4339
```
4440

45-
If the sum is evenly divisible by 10, then the number is valid. This number is valid!
41+
If the sum is evenly divisible by 10, then the number is valid.
42+
This number is valid!
4643

47-
## Example 2: invalid credit card number
44+
### Example 2: invalid credit card number
4845

4946
```text
5047
8273 1232 7352 0569
@@ -63,3 +60,5 @@ Sum the digits
6360
```
6461

6562
57 is not evenly divisible by 10, so this number is not valid.
63+
64+
[luhn]: https://en.wikipedia.org/wiki/Luhn_algorithm

0 commit comments

Comments
 (0)