Ethiopian multiplication: Difference between revisions
Content added Content deleted
(→{{header|J}}: Removed second section as contrary to the comment, it does not obey the letter of the task description as it fails to use the three functions.) |
|||
Line 731:
import "fmt"
func halve(i int) int { return i
func double(i int) int { return i*2
func isEven(i int) bool { return
func ethMulti(i, j int) (r int) {
for ; i > 0; i, j = halve(i), double(j) {
if !isEven(i) {
r += j
}
}
return▼
▲ return
}
func main() {
fmt.Printf("17 ethiopian 34 = %d\n", ethMulti(17, 34))
}
=={{header|Haskell}}==
|