Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,22 @@
ClearAll[EgyptianDivide]
EgyptianDivide[dividend_, divisor_] := Module[{table, i, answer, accumulator},
table = {{1, divisor}};
i = 1;
While[Last[Last[table]] < dividend,
AppendTo[table, 2^i {1, divisor}];
i++
];
table //= Most;
answer = 0;
accumulator = 0;
Do[
If[accumulator + t[[2]] <= dividend,
accumulator += t[[2]];
answer += t[[1]]
]
,
{t, Reverse@table}
];
{answer, dividend - accumulator}
]
EgyptianDivide[580, 34]