-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesercizio5.cpp
More file actions
36 lines (30 loc) · 751 Bytes
/
esercizio5.cpp
File metadata and controls
36 lines (30 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <cmath>
using namespace std;
double calcola_distanza_2d(double x1, double y1, double x2, double y2) {
return sqrt(pow((x2-x1),2) + pow((y2-y1),2));
}
int main() {
int n1, n2;
bool mcd_trovato=false;
cout<<"inserisci due numeri naturali";
cin>>n1>>n2;
if (n2>n1) {
for (int i=n1+1;i<n2;i++) {
cout<< i <<" ";
}
}
else {
for (int i=2;i<=n2;i++) {
if (n2%i==0&&n1%i==0) {
cout<<"m.c.d tra "<<n1<<" e "<<n2<<" e' "<<i;
mcd_trovato=true;
break;
}
}
if (mcd_trovato==false) {
cout<<"m.c.d tra "<<n1<<" e "<<n2<<" e' 1";
}
}
return 0;
}