|
2 | 2 |
|
3 | 3 | Convert a number, represented as a sequence of digits in one base, to any other base. |
4 | 4 |
|
5 | | -Implement general base conversion. Given a number in base **a**, |
6 | | -represented as a sequence of digits, convert it to base **b**. |
| 5 | +Implement general base conversion. |
| 6 | +Given a number in base **a**, represented as a sequence of digits, convert it to base **b**. |
7 | 7 |
|
8 | 8 | ## Note |
9 | 9 |
|
10 | 10 | - Try to implement the conversion yourself. |
11 | 11 | Do not use something else to perform the conversion for you. |
12 | 12 |
|
13 | | -## About [Positional Notation](https://en.wikipedia.org/wiki/Positional_notation) |
| 13 | +## About [Positional Notation][positional-notation] |
14 | 14 |
|
15 | | -In positional notation, a number in base **b** can be understood as a linear |
16 | | -combination of powers of **b**. |
| 15 | +In positional notation, a number in base **b** can be understood as a linear combination of powers of **b**. |
17 | 16 |
|
18 | | -The number 42, *in base 10*, means: |
| 17 | +The number 42, _in base 10_, means: |
19 | 18 |
|
20 | | -(4 * 10^1) + (2 * 10^0) |
| 19 | +`(4 * 10^1) + (2 * 10^0)` |
21 | 20 |
|
22 | | -The number 101010, *in base 2*, means: |
| 21 | +The number 101010, _in base 2_, means: |
23 | 22 |
|
24 | | -(1 * 2^5) + (0 * 2^4) + (1 * 2^3) + (0 * 2^2) + (1 * 2^1) + (0 * 2^0) |
| 23 | +`(1 * 2^5) + (0 * 2^4) + (1 * 2^3) + (0 * 2^2) + (1 * 2^1) + (0 * 2^0)` |
25 | 24 |
|
26 | | -The number 1120, *in base 3*, means: |
| 25 | +The number 1120, _in base 3_, means: |
27 | 26 |
|
28 | | -(1 * 3^3) + (1 * 3^2) + (2 * 3^1) + (0 * 3^0) |
| 27 | +`(1 * 3^3) + (1 * 3^2) + (2 * 3^1) + (0 * 3^0)` |
29 | 28 |
|
30 | 29 | I think you got the idea! |
31 | 30 |
|
32 | | -*Yes. Those three numbers above are exactly the same. Congratulations!* |
| 31 | +_Yes. Those three numbers above are exactly the same. Congratulations!_ |
| 32 | + |
| 33 | +[positional-notation]: https://en.wikipedia.org/wiki/Positional_notation |
0 commit comments