int main() { int smallest = 0; int test = 100; while(!smallest) { if(canDivide(test)) smallest = test; ++test; } printf("%d\n", smallest); return 0; }
Expression* Logarithm::divide(Expression* dividend){ if(canDivide(dividend)){ Number* retNum = new Number(this->toDecimal()/dividend->toDecimal()); return retNum; } Logarithm* exLog = static_cast<Logarithm*>(dividend); bool sameBase = exLog->getBase()->toDecimal() == this->getBase()->toDecimal(); bool sameArg = exLog->getArgument()->toDecimal() == this->getArgument()->toDecimal(); if(sameBase && sameArg){ Number* one = new Number(1); return one; } MultiplicationVector* retEx = new MultiplicationVector(this, dividend); return retEx; }