#include<stdio.h>
#include<conio.h>
int A,B,GCF=1,K,X;
main()
{
clrscr();
printf("First integer:");
scanf("%d",&A);
printf("\nSecond integer:");
scanf("%d",&B);
X=A*B;
for(K=2; A!=1 B!=1; K++)
{
while (A%K==0 && B%K==0)
{
A/=K;
B/=K;
GCF*=K;
}
while(A%K==0)
{
A/=K;
}
while(B%K==0)
{
B/=K;
}
}
printf("GCF is %d",GCF);
getch();
}
Chat with our AI personalities
You need at least two numbers to find a GCF.
The greatest common factor of two or more prime numbers is 1.
The greatest common factor of the numbers 323 and 391 is 17.
The greatest common factor of the numbers 16 and 56 is 8.
If the greatest common factor is 1, then the numbers are said to be co-prime or relatively prime.