最大公约数(递归)(c++)

    科技2026-01-16  9

    用递归求最大公约数是怎么做到的呢?请看如下:

    #include<bits/stdc++.h> using namespace std; int n,m; int dg(int a,int b) { if(a%b==0) return b; return dg(b,a%b); } int main() { cin>>n>>m; cout<<dg(n,m); return 0; }
    Processed: 0.017, SQL: 9