JohnGH
2
Q:

find gcd iteratively

// C program to find HCF of two 
// numbers iteratively. 
#include <stdio.h> 
  
int hcf(int a, int b) 
{ 
    while (a != b) { 
        if (a > b)         
            a = a - b;         
        else        
            b = b - a;         
    } 
    return a; 
} 
int main() 
{ 
    int a = 60, b = 96; 
    printf("%d\n", hcf(a, b));  
    return 0; 
} 
0

Tags

New to Communities?

Join the community