--- title: Ethiopian multiplication id: 599d1566a02b571412643b84 challengeType: 5 videoUrl: '' localeTitle: 埃塞俄比亚的乘法 --- ## Description

埃塞俄比亚乘法是一种仅使用加法,加倍和减半来乘以整数的方法。

方法:

取两个数字相乘,然后将它们写在两列的顶部。在左侧列中反复将最后一个数字减半,丢弃任何余数,并将结果写入同一列中的最后一个,直到您写入值1.在右侧列中重复加倍最后一个数字并写入结果如下。在左侧列显示的同一行中添加结果时停止1.检查生成的表并丢弃左列中的值为偶数的任何行。将右侧列中的值相加,以产生将原始两个数相乘的结果

例如:17×34

17 34

将第一列减半:

17 34

8

4

2

1

加倍第二列:

17 34

8 68

4 136

2 272

1 544

第一个单元格为偶数的删除行:

17 34

8 68

4 136

2 272

1 544

将右侧列中的剩余数字相加:

17 34

8 -

4 ---

2 ---

1 544

====

578

所以17乘以34,埃塞俄比亚方法是578。

任务:

任务是定义三个命名函数/方法/过程/子例程:

一个将一个整数减半,一个减半整数,一个整数是偶数。

使用这些函数创建一个执行埃塞俄比亚乘法的函数。

## Instructions
## Tests
```yml tests: - text: eth_mult是一个功能。 testString: 'assert(typeof eth_mult === "function", "eth_mult is a function.");' - text: 'eth_mult(17,34)应该返回578 。' testString: 'assert.equal(eth_mult(17, 34), 578, "eth_mult(17,34) should return 578.");' - text: 'eth_mult(23,46)应该返回1058 。' testString: 'assert.equal(eth_mult(23, 46), 1058, "eth_mult(23,46) should return 1058.");' - text: 'eth_mult(12,27)应该返回324 。' testString: 'assert.equal(eth_mult(12, 27), 324, "eth_mult(12,27) should return 324.");' - text: 'eth_mult(56,98)应该返回5488 。' testString: 'assert.equal(eth_mult(56, 98), 5488, "eth_mult(56,98) should return 5488.");' - text: 'eth_mult(63,74)应该返回4662 。' testString: 'assert.equal(eth_mult(63, 74), 4662, "eth_mult(63,74) should return 4662.");' ```
## Challenge Seed
```js function eth_mult (a, b) { // Good luck! } ```
## Solution
```js // solution required ```