GCD function for C

前端 未结 4 1848
礼貌的吻别
礼貌的吻别 2021-02-15 18:04

Q 1. Problem 5 (evenly divisible) I tried the brute force method but it took time, so I referred few sites and found this code:

#include
int gcd(i         


        
4条回答
  •  灰色年华
    2021-02-15 18:41

    I executed this statements for GCD :

    #include
    #include
    int main(){
       int l, s,r;
    
       printf("\n\tEnter value : ");
       scanf("%d %d",&l,&s);
    
      while(l%s!=0){
        r=l%s;
        l=s;
        s=r;
      }
      printf("\n\tGCD = %d",s);
      getch();
    }
    

提交回复
热议问题