CS255 Syllabus
Multiplication with Base-5 Numbers
• Base-5 number system: number system based on number 5

• Has 5 digits: 0, 1, 2, 3, 4
• Value of digits increase by a factor of 5 for each position
```   Example:

243(5) = 2 x 52 + 4 x 51 + 3 x 50
= 2 x 25 + 4 x 5 + 3 x 1
= 50 + 20 + 3 = 73
```

• You must remember that the digit 0 follows the digit 4 in the base-5 system

• So:
```     1 + 1 =  2     1 + 2 =  3     1 + 3 =  4    1 + 4 = 10
2 + 1 =  3     2 + 2 =  4     2 + 3 = 10    2 + 4 = 11
3 + 1 =  4     3 + 2 = 10     3 + 3 = 11    3 + 4 = 12
4 + 1 = 10     4 + 2 = 11     4 + 3 = 12    4 + 4 = 13
```
• More complex examles...

Example 1:
```       12          =  1 x 51 + 2 x 50 = 7(10)
+   2          =           2 x 50 = 2(10)
-------
14          =  1 x 51 + 4 x 50 = 9(10)
```
Example 2:
```       12          =  1 x 51 + 2 x 50 =  7(10)
+   3	   =           3 x 50 =  3(10)
-------
20          =  2 x 51 + 0 x 50 = 10(10)

2 + 3 = 10, write down 0 and remember carry 1
1 + carry 1 = 2
```
Example 3:
```       141         = 1 x 52 + 4 x 51 + 1 x 50 = 46(10)
+ 2340         = 2 x 53 + 3 x 52 + 4 x 51 + 0 x 50 = 345(10)
-------
3031         = 3 x 53 + 0 x 52 + 3 x 51 + 1 x 50 = 391(10)

1 + 0 = 1
4 + 4 = 13, write down 3, remember carry 1
1 + 3 = 4, add carry 1 = 10, write down 0, carry 1
2 + carry 1 = 3
```

• Base-5 multiplication

• In order to perform multiplication in base-5, we need to "memorize" the multiplication table for base-5.

• The following is the multiplcation table for base-5:
```        |  1   2   3   4
----+-------------------
1 |  1   2   3   4
2 |  2   4  11  13
3 |  3  11  14  22
4 |  4  13  22  31
```
• 2x3 = 11, because:
```       2 x 3 = value 6 ----- which is represented in base-5 as 11  (1 x 5 + 1 = 6)
```
• 2x4 = 13, because:
```       2 x 4 = value 8 ----- which is represented in base-5 as 13  (1 x 5 + 3 = 8)
```
• 3x3 = 14, because:
```       3 x 3 = value 9 ----- which is represented in base-5 as 14  (1 x 5 + 4 = 9)
```
• 3x4 = 22, because:
```       3 x 4 = value 12 ----- which is represented in base-5 as 22  (2 x 5 + 2 = 12)
```
• 4x4 = 31, because:
```       4 x 4 = value 16 ----- which is represented in base-5 as 31  (3 x 5 + 1 = 16)
```

• We can now perform base-5 multiplication using the above table.

Example 1:

```    Base-5         Value

23           2 x 5 + 3 = 13(10)
x  4                     = 4(10)
----
202           4 x 3 = 22, write down 2 and remember carry 2
4 x 2 = 13, add the carry 2:
13 + 2 = 20
write down 0 and remember carry 2
```
In other words: 23(5) x 4(5) = 202(5)

We can check the correctness:

```      202(5) = 2 x 52 + 0 x 51 + 2 x 50
= 2 x 25 + 2
= 52(10)  (which is equal to 13(10) x 4(10))
```

Example 2:

```    Base-5         Value

43           4 x 5 + 3 = 23(10)
x 32           3 x 5 + 2 = 17(10)
----
141
2340
-----
3031
```
In other words: 43(5) x 32(5) = 3031(5)

We can check the correctness:

```      3021(5) = 3 x 53 + 0 x 52 + 3 x 51 + 1 x 50
= 3 x 125 + 0 x 25 + 3 x 5 + 1
= 375 + 15 + 1
= 391(10) (which is equal to 23(10) x 17(10))
```