1 solutions

  • 0
    @ 2025-3-3 16:33:40

    C :

    #include<stdio.h>
    long long m,n;
    long long f(long long a,long long b)
    {
    	if(a%b==0)	return b;
    	return f(b,a%b);
    }
    int main()
    {
    	scanf("%lld %lld",&m,&n);
    	printf("%lld",f(m,n));
    	return 0;
    } 
    

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    
    int main(){
    	long long a,b,t;
    	cin>>a>>b;
    	while(a % b != 0){
    		t = a % b;
    		a = b;
    		b = t;
    	} 
    	cout<<b<<endl;
    	
    	 
        return 0;
    }
    
    

    Python :

    sr=input().split()
    m=int(sr[0])
    n=int(sr[1])
    r=m%n
    while(r!=0):
       m=n
       n=r
       r=m%n
    print(n)
    
    • 1

    Information

    ID
    10644
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By