P041.c (541B)
1 /* Write a program to enter two numbers and check they are co-prime or not. 2 co-prime when HCF = 1 3 */ 4 5 #include <stdio.h> 6 int main() 7 { 8 int a, b, temp, temp_a, temp_b; 9 printf("Enter two number : "); 10 scanf("%d %d", &a, &b); 11 temp_a = a; 12 temp_b = b; 13 while (b > 0) 14 { 15 temp = a; 16 a = b; 17 b = temp % b; 18 } 19 if (a == 1) 20 { 21 printf("\n(%d, %d) is co-prime.", temp_a, temp_b); 22 } 23 else 24 { 25 printf("\n(%d, %d) is not co-prime.", temp_a, temp_b); 26 } 27 return 0; 28 }