gcd of two numbers in c

Solutions on MaxInterview for gcd of two numbers in c by the best coders in the world

showing results for - "gcd of two numbers in c"
Cassia
20 Mar 2017
1#include <stdio.h>
2int main()
3{
4    int n1, n2, i, gcd;
5
6    printf("Enter two integers: ");
7    scanf("%d %d", &n1, &n2);
8
9    for(i=1; i <= n1 && i <= n2; ++i)
10    {
11        // Checks if i is factor of both integers
12        if(n1%i==0 && n2%i==0)
13            gcd = i;
14    }
15
16    printf("G.C.D of %d and %d is %d", n1, n2, gcd);
17
18    return 0;
19}
20
Abigael
10 Aug 2018
1#include <stdio.h>
2int main()
3{
4    int n1, n2;
5    
6    printf("Enter two positive integers: ");
7    scanf("%d %d",&n1,&n2);
8
9    while(n1!=n2)
10    {
11        if(n1 > n2)
12            n1 -= n2;
13        else
14            n2 -= n1;
15    }
16    printf("GCD = %d",n1);
17
18    return 0;
19}
queries leading to this page
nrgcd in chow can we make gcd of two numbers maximumfind gcd of two numbersgcd of two numbers without recursiongcd of 2 numbers and 2 integersgcd 2 numbershow to calculate gcd of two numbershow to cal gcd inchow find gcd using while loopwap using function to find gcd of two numbers gcd will be printed in the calling functiongreatest common divisor in chow to compute gcd of two numbersfind gcd of 2 numbersc program for gcd 0 inputlogic for gcd of two numbers2 numbers with gcd 3d 4program to calculate gcd in cc program greatest common divisorgcd of two equal numbersc programming for gcd of two numbersc prorgam to find hcf of two numbershcf in ccode forgcd for 2 numbersfind the fcg lch of tow given number in ccode for finding gcd of two numbersgcd of two numbers in cwrite a function gcd that takes two natural numbers and calculates their gcd example 3a gcd 286 2c 15 29 should return 3 gcd of two numbers congcd of two numbers logicfind the hcf of two numbers in ca c program to find hcf 28gcd 29 of two numbershow to get the gcd of 2 numbersgcd of two number in cgcd of given more than two numbershcf 2fgcd question in ccode for gcd of two numbers in cgcd of numbers in cgcd of any number and 0find gcd of a number in cgcd 282 2c 3 2c 6 29gcd between two numbersgcd of more than two numbers in cefficient program to find gcd of two numbersgcd program in ctwo numbers both have gcd 3d1gcd of more than two numbershow to find gcdc program to find find the greatest common divisor of two numbersprogram to find gcdgcd and hcf program in cgcd of 2 numbers practicewhat is gcd of two numbershcf in c language2 numbers with gcd 3d 3program to write gcd of two numbers in c for loophow to find gcd programprogram to calculate gcd of two numbersprogram for gcd of two numberscode for gcdhow to find gcd of two numbershow to make gcd of two numbers 1gcd of 5 and 10 numberscalculate two number whose gcd is of c digitcode for finding gcd of two numbers in cgcd of n numbers in chow to find gcd of two numbers in c 2bgcd of two numbers for a 3ebgcd and lcm of two numbers in chow to find the gcd of 2 numbersgcd code in cgcd of two or more numbers in cwhen is gcd of two numbers 1how to find gcd of two numbers in cto find hcf gcd of two numbers in cgcd of multiple numbers competitive find gcd of 3 numbers c programmingprogram to find gcd of two numbers 2c gcd meanshcf program in ctwo numbers for calculating gcdhow to find the gcd of two numbersdevise an algorithm that reads two integers and then finds and prints the hcf 2fgcd using for loop program to calculate gcd of two number in c 27max common divisor cgcd function in csyntax for gcd in c gcd and hcm program in cc program for gcd input 0gcd for input 0 in chcf between two numbers in cc program to add twon numbersgcd and lcm of two numbers in c using functionwrite a c program to calculate the gcd of two numbers using the eucledian algorithmgcd of multiple numbersc program to calculate gcd of two numbershcf of two numbers in cfind greatest common divider in cc program to find gcd of two numbers logicwrite a c program to find gcd of three numbersgcd of three numbers in cfinding gcd of two numberscalculate gcd of 2 numbersgcd of two same numbers are always the given number 3fcode for gcd in chcf and gcd of two numbers in chow to find gcd of two numbers easilyprogram to print greatest common divisorgcd formula in cgcd of two numbers using function in cwrite a c program to find hcf 28gcd 29 of two numbers how to find the gcd in cgcd cwhen is the gcd of two numbers 1gcd of two numbers withrecursion 2fgcd cc program to fin gcd of two numberscalcualte gcd of two numbers programgcd of two large numbers in cgcd of two numbers c programgcd of two numbers using function in c 2b 2bgcd of two numbers in c using recursionwrite a program to find gcd of two numbersfunction to find the gcd of two numbersgcd of 10 numbers in c programminggcd 2810 2 29gcd calculation in programinggcd of two numbers how to findgcd of two numbers mathsgcd operator in cc program to find gcd of two numbers gcd of any 3 given numbers algorithm in cc program to find gcd of two numbersgcd of two numbers formulagcd of 2 numbers in chow to find gcd in cgcd number in cgcd of two numberswriting a program that calculates the gcdc program to find gcd of two numbers loicwrite a c program gcd of two numbersgcd for two numbersgcd of a number in c gcd of two numbers 876 2c765hcf 2fgcd of two numbers in cgcd of two numbers maximumgcd of two numbers 2 and 3write a c program to find gcd 28hcf 29 of two numbers using arraysgcd of a single number in cgcd in c of multiple numbersgcd of two numbers in mathfind gcd of two numbers in cc program to find gcd of n numbersgcd of 3 numbers in cgcd of two numbers programmizhow to cal gcd in ccalculating gcd of two numbersgcd of 1 to n numbers in cgcd of two numbers pluscheck greatest factor in ccode to find gcdgcd of two numbers in c most efficientgcd of 2 numbersgcd of 2 numbers formulafind the gcd 28greatest common divisor 29 of 2 given intgcd codeevaluate gcd of two numbers in cgcd of two integer numberscompute gcd of two numbersgcd of two numbers in c 2b 2bwrite a function in c that will find the gcd of two numbers gcd calculator cgcd of two numbers is 1write a c program to find hcf 28gcd 29 of two numbersgcd of two numbers mathshow to find gcd of two numbers in c in short formgcd of numsbers in cgcd of two numbers gfgprogram to write gcd of two numbers in c for lookfind out gcd of multiple numbers in cshortest c program to compute gcd of two numbersgcd of 2 numbers is1c program to find hcf of two numbersgcd in c programgcd of two numbers onlineprogram to find gcd of two numbersprogram for gcd in cfind hcf of two numbers in cwap to find gcdgcd for three numbers c programmingprogram to find hcf of two numbersgcd of 2 number in cgcd of two numbers from than 1c program that find gcd of three numbersprogram to find greatest uncommon facorcode gcd of 2 numbers 3a the greatest common divisor 28gcd 29 of two integers 28of which at least one is nonzero 29 is the largest positive integer that divides the numbers write a c non recursive function nrgcd that accepts two integers gcd of 2 numbers are 1gcd of two numbers algorithmwhat is gcd of 2 numberscode to find gcd of two numbersc program for gcd of two numbersgcd in c codewrite a c program to find hcf 28gcd 29 of two numbers 3fgcd of two numbers stlto find gcd of two numbersgcd of two numbers using euclidean algorithm in cprogram to write gcd of two numbers in cgcd in cto find the gcd of two numberswrite a program that reads n numbers from the input and uses the function gcd count themgcd of two numbers in c 2b 2b using functionhow to find gcd of 2 numberscalculate gcd of two numbershow to compute the gcd of two integers using the gcd functiongcdof 2 numbers prograsmming formulagcd of two numbers in c