Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

highest common factor algorithm in c

// C program to find GCD of two numbers
#include <stdio.h>
 
// Recursive function to return gcd of a and b
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
// Driver program to test above function
int main()
{
    int a = 98, b = 56;
    printf("GCD of %d and %d is %d ", a, b, gcd(a, b));
    return 0;
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #highest #common #factor #algorithm
ADD COMMENT
Topic
Name
2+2 =