fork download
  1. #include <stdio.h>
  2.  
  3. int fac(int hcf,int h)
  4.  
  5. {
  6.  
  7. int j,i;
  8.  
  9.  
  10. for( i=1; i <=hcf && i <=h; ++i)
  11.  
  12. {
  13.  
  14.  
  15. if(hcf%i==0 && h%i==0)
  16.  
  17. j=i;
  18.  
  19. }
  20.  
  21.  
  22. printf("H.C.F of %d and %d is %d", hcf, h, j);
  23.  
  24.  
  25. }
  26.  
  27.  
  28. int main()
  29. {
  30.  
  31. int gcd,i;
  32.  
  33. printf("Enter two numbers : \n");
  34.  
  35. scanf("%d %d", &gcd, &i);
  36.  
  37. fac(gcd,i);
  38.  
  39. return 0;
  40.  
  41. }
Success #stdin #stdout 0s 10320KB
stdin
22
33
stdout
Enter two numbers : 
H.C.F of 22 and 33 is 11