OpenGenus / cosmos

World's largest Contributor driven code dataset | Used in Quark Search Engine, @OpenGenus IQ, OpenGenus Visual Project
http://internship.opengenus.org
GNU General Public License v3.0
13.58k stars 3.69k forks source link

Co- Prime check in an easy approach using C #6568

Open ShuvamBag opened 2 years ago

ShuvamBag commented 2 years ago

include

int coprime(int num1, int num2)
{
int min, count, flag = 1;

min = num1 < num2 ? num1 : num2;  

for(count = 2; count <= min; count++)  
{  
    if( num1 % count == 0 && num2 % count == 0 )  
    {  
        flag = 0;  
        break;  
    }  
}  

return(flag);  

}

int main()
{
int n1, n2;

printf("Enter 2 positive numbers\n");  
scanf("%d%d", &n1, &n2);  

if( coprime(n1, n2) )  
{  
    printf("%d and %d are co-prime numbers.\n", n1, n2);  
}  
else  
{  
    printf("%d and %d are not co-prime numbers.\n", n1, n2);  
}  

return 0;  

}

// This is a co- prime number check program made using c.

HridoyHazard commented 2 years ago

what do you want? if you want to contribute plz make a pr on this issue. thanks

AdityaShaw1 commented 2 years ago

can u pls assign me to this issue??

pinak01 commented 1 year ago

i want to contribute in this

sakshams23 commented 1 year ago

hello sir, I would like to contribute in this issue. Please assign this to me.

PrathamKumar125 commented 1 year ago

@AdiChat @ShuvamBag please review the merged code.