c - How to calculate the gcd of two numbers via Euclidean's algorithm -
c - How to calculate the gcd of two numbers via Euclidean's algorithm -
i have written sample programme calculate gcd of 2 numbers. here is:
#include stdio.h int main(void) { int m, n, rem; printf("enter 2 numbers consecutively(with space between them): "); scanf("%d %d", &m, &n); while (m) { n = m % n; //problem here n = rem; } printf("%d gcd", rem); homecoming 0; }
i think supposed store output of modulo operator statement in rem far programme not respond input given. can give me clue.
can give me clue.
for starters you're not changing m
within loop can't end.
c
Comments
Post a Comment