Difference between revisions of "TADM2E 1.28"

From Algorithm Wiki
Jump to: navigation, search
(Recovering wiki)
 
(Recovering wiki)
Line 1: Line 1:
<pre>
+
<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 &gt;= denominator) {
+
   while(numerator >= denominator) {
 
       numerator -= denominator;
 
       numerator -= denominator;
 
       quotient++;
 
       quotient++;
Line 11: Line 11:
 
   return quotient;
 
   return quotient;
 
}
 
}
&lt;/pre&gt;
+
</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;
}