Problem 15

21 comments on “Problem 15”


  • Sajal

    #include
    using namespace std;
    int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<__gcd(a,__gcd(b,c));
    return 0;
    }


  • shushank

    Python
    a=int(input())
    b=int(input())
    c=int(input())
    l1=[]
    d=min(a,b,c)
    for i in range(2,d+1):
    a1=i
    if a%a1==0 and b%a1==0 and c%a1==0:
    l1.append(a1)
    if len(l1)>0:
    print(max(l1))
    else:
    print(“No GCD “)


  • Sunny

    #Python3

    num=[]
    num=list(map(int,input().rstrip().split()))
    num=sorted(num)
    gc=[]
    i=1
    for i in range(1,num[0]+1):
    if (num[0]%i==0) and (num[1]%i==0) and (num[2]%i==0):
    gcd=i

    print(gcd)


  • Raman

    // Online C compiler to run C program online
    #include

    int main() {
    int x,y,z,min,gcd=0,i;

    scanf(“%d”,&x);
    scanf(“%d”,&y);
    scanf(“%d”,&z);

    if(x<y && x<z){
    min=x;
    }
    else if(y<x && y<z){
    min=y;
    }
    else if(z<x && z<y){
    min=z;
    }

    for(i=1;i<=min;i++){
    if(x%i==0 && y%i==0 && z%i==0){
    gcd=i;
    }
    }
    if(gcd==0){
    printf("there is no GCD");
    }
    else{
    printf("GCD is :%d",gcd);
    }
    return 0;
    }


  • rohan

    sir similarly LCM of three numbers
    #include
    int main()
    {
    int i,l,m,x,y,z,max=999999;
    printf(“enter 3 numbers”);
    scanf(“%d%d%d”,&x,&y,&z);
    if(x>y)
    m=x>z?x:z;
    else
    m=y>z?y:z;
    for(i=m;i<=max;++i)
    {
    if(i%x==0 && i%y==0 && i%z==0)
    {l=i;
    break;
    }
    }
    printf("\n%d",l);
    return 0;
    }