Skip to content

@jinthagerman /gist:4133720
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Simplify ratio
int n1 = 320;
int n2 = 480;
simplifyRatio(&n1, &n2);
printf("%d %d", &n1, &n2);
int highestCommonFactor(int n1, int n2) {
int remainder = n1%n2;
if (remainder != 0) {
return highestCommonFactor(n2, remainder);
} else {
return n2;
}
}
void simplifyRatio(int* n1, int* n2) {
int HCF = highestCommonFactor(*n1, *n2);
*n1 = *n1/HCF;
*n2 = *n2/HCF;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.