Difference between revisions of "TADM2E 1.28"
From Algorithm Wiki
(Recovering wiki) |
(Recovering wiki) |
||
Line 1: | Line 1: | ||
− | + | <pre> | |
// Note: This only works for positive values! | // Note: This only works for positive values! | ||
int divide(int numerator, int denominator) { | int divide(int numerator, int denominator) { | ||
int quotient = 0; | int quotient = 0; | ||
− | while(numerator | + | while(numerator >= denominator) { |
numerator -= denominator; | numerator -= denominator; | ||
quotient++; | quotient++; | ||
Line 11: | Line 11: | ||
return quotient; | return quotient; | ||
} | } | ||
− | + | </pre> |
Revision as of 18:24, 11 September 2014
// Note: This only works for positive values! int divide(int numerator, int denominator) { int quotient = 0; while(numerator >= denominator) { numerator -= denominator; quotient++; } return quotient; }