Module: GCD(최대 공약수)


Problem

3/10

재귀 GCD: 시작(C++)

Problem

두 개의 자연수 AB가 주어진다. 최대 공약수를 찾는 데 필요합니다.
 
입력
두 개의 자연수 입력 AB (\(A, B <= 10^9\)) .
 
출력 
GCD AB를 출력하는 데 필요합니다.

누락된 코드 조각을 프로그램에 붙여넣습니다.

예시
<헤드> <일># <몸>

입력 출력
1 12 42 6
Write the program below
#include<iostream>
using namespace std;
int gcd(int a, int b){            
}
int main(){
    int n,m;
    cin >> n >> m;
    cout << gcd(n, m);
    return 0;
}
            

     

Program check result

To check the solution of the problem, you need to register or log in!