Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- double nod(int a,int b){
- int max;int p;
- if(a>b){
- max=a;
- }
- else{ max=b;
- }
- for(int i=max;i>=1;--i){
- if(((a%i)==0)&&((b%i)==0)){
- p=i;break;
- }
- }
- return p;
- }
- int main(){
- int a,b; cin>>a>>b;
- double k=nod(a,b);
- cout<<k;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement