cosmos icon indicating copy to clipboard operation
cosmos copied to clipboard

Co- Prime check in an easy approach using C

Open ShuvamBag opened this issue 2 years ago • 5 comments

#include<stdio.h>

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.

ShuvamBag avatar Oct 09 '22 13:10 ShuvamBag

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

HridoyHazard avatar Oct 10 '22 12:10 HridoyHazard

can u pls assign me to this issue??

AdityaShaw1 avatar Oct 16 '22 05:10 AdityaShaw1

i want to contribute in this

pinak01 avatar Oct 08 '23 20:10 pinak01

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

sakshams23 avatar Oct 16 '23 05:10 sakshams23

@AdiChat @ShuvamBag please review the merged code.

PrathamKumar125 avatar Oct 24 '23 11:10 PrathamKumar125