My solution is C/C++ code and it makes many additions (200402), but anyway...
#include <iostream>int total = 0;int sum(int a, int b){++total; return a + b;}int divide(int a, int b){ int x = 1; if (a < b) return 0; else return sum(x, divide(sum(a, -b), b));}int main(){ for (int i = 1; i <= 200; ++i) for (int j = 1; j <= 200; ++j) { if (divide(i, j) != (i / j)) std::cout << "Failure: a="<< i << " b="<< j << "\n"; } std::cout << "Total additions: "<< total << std::endl; system("pause");}
And the output is:
Total additions: 200402Press any key to continue . . .