/* The function factDivide divides two factored integers. Specifically, fmultiply( a, b) replaces a by the quotient a/b. (b remains unchanged.)
If b does not divide a, an error occurs. */
void factDivide(
FactoredInt *const a,
FactoredInt *const b) /* a = a / b */
{ Unsigned aIndex = 0, bIndex = 0, i;
a->prime[a->noOfFactors] = b->prime[b->noOfFactors] = MAX_INT; while ( a->prime[aIndex] < MAX_INT && b->prime[bIndex] < MAX_INT ) if ( a->prime[aIndex] < b->prime[bIndex] )
++aIndex; elseif ( a->prime[aIndex] == b->prime[bIndex] ) if ( a->exponent[aIndex] > b->exponent[bIndex] )
a->exponent[aIndex++] -= b->exponent[bIndex++]; elseif ( a->exponent[aIndex] == b->exponent[bIndex] ) {
--a->noOfFactors; for ( i = aIndex ; i <= a->noOfFactors ; ++i ) {
a->prime[i] = a->prime[i+1];
a->exponent[i] = a->exponent[i+1];
}
++bIndex;
} else
ERROR( "factDivide", "Divisor does not divide dividend in factored " "integer division.") else
ERROR( "factDivide", "Divisor does not divide dividend in factored " "integer division.")
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.