Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a[100];
- int cmmdc(int st, int dr)
- {
- int m,c,b,r;
- if(st==dr)
- return a[st];
- else
- {
- m=(st+dr)/2;
- b=cmmdc(st,m);
- c=cmmdc(m+1,dr);
- r=b%c;
- while(r)
- {
- b=c;
- c=r;
- r=b%c;
- }
- return c;
- }
- }
- int main()
- {
- int n, i;
- cin>>n;
- for(i=1; i<=n; i++)
- cin>>a[i];
- cout<<cmmdc(1, n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement