Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,17 @@
halve = (n) -> Math.floor n / 2
double = (n) -> n * 2
is_even = (n) -> n % 2 == 0
multiply = (a, b) ->
prod = 0
while a > 0
prod += b if !is_even a
a = halve a
b = double b
prod
# tests
do ->
for i in [0..100]
for j in [0..100]
throw Error("broken for #{i} * #{j}") if multiply(i,j) != i * j