|
1 | 1 | # Instructions
|
2 | 2 |
|
3 |
| -Your task is to convert a number into a string that contains raindrop sounds corresponding to certain potential factors. |
4 |
| -A factor is a number that evenly divides into another number, leaving no remainder. |
5 |
| -The simplest way to test if one number is a factor of another is to use the [modulo operation][modulo]. |
| 3 | +Your task is to convert a number into its corresponding raindrop sounds. |
6 | 4 |
|
7 |
| -The rules of `raindrops` are that if a given number: |
| 5 | +If a given number: |
8 | 6 |
|
9 |
| -- has 3 as a factor, add 'Pling' to the result. |
10 |
| -- has 5 as a factor, add 'Plang' to the result. |
11 |
| -- has 7 as a factor, add 'Plong' to the result. |
12 |
| -- _does not_ have any of 3, 5, or 7 as a factor, the result should be the digits of the number. |
| 7 | +- is divisible by 3, add "Pling" to the result. |
| 8 | +- is divisible by 5, add "Plang" to the result. |
| 9 | +- is divisible by 7, add "Plong" to the result. |
| 10 | +- **is not** divisible by 3, 5, or 7, the result should be the number as a string. |
13 | 11 |
|
14 | 12 | ## Examples
|
15 | 13 |
|
16 |
| -- 28 has 7 as a factor, but not 3 or 5, so the result would be "Plong". |
17 |
| -- 30 has both 3 and 5 as factors, but not 7, so the result would be "PlingPlang". |
18 |
| -- 34 is not factored by 3, 5, or 7, so the result would be "34". |
| 14 | +- 28 is divisible by 7, but not 3 or 5, so the result would be `"Plong"`. |
| 15 | +- 30 is divisible by 3 and 5, but not 7, so the result would be `"PlingPlang"`. |
| 16 | +- 34 is not divisible by 3, 5, or 7, so the result would be `"34"`. |
19 | 17 |
|
| 18 | +~~~~exercism/note |
| 19 | +A common way to test if one number is evenly divisible by another is to compare the [remainder][remainder] or [modulus][modulo] to zero. |
| 20 | +Most languages provide operators or functions for one (or both) of these. |
| 21 | +
|
| 22 | +[remainder]: https://exercism.org/docs/programming/operators/remainder |
20 | 23 | [modulo]: https://en.wikipedia.org/wiki/Modulo_operation
|
| 24 | +~~~~ |
0 commit comments