Trovare il mcm e il MCD di due numeri
Per trovare il minimo comune multiplo è stata usata la formula del mcm e l'algoritmo di Euclide per trovare il MCD. L'algoritmo è stato scritto sotto in pesudocodifica e in codifica c++ (o in inglese: c plus plus) .
ALGORITMO IN PSEUDOCODIFICA
VAR N1:integer;
N2:integer;
N3:integer;
N4:integer;
R:integer;
MCD:integer;
mcm:integer;
BEGIN
OUTPUT("inserire il primo numero");
INPUT(N1);
OUTPUT("inserire il secondo numero");
INPUT(N2);
IF (N2 > N1) THEN
R = N1;
N1 = N2;
N2 = R;
ENDIF
N3 = N1;
N4 = N2;
//Calcolo MCD
R = N3 MOD N4;
WHILE(R <> 0)
N3 = N4;
N4 = R;
R = N3 MOD N4;
ENDWHILE
MCD = N4;
//Calcolo mcm
MCM = (N1*N2)/MCD;
OUTPUT("MCD = ", MCD, " MCM = " MCM);
OUTPUT("Numeri iniziali = ", N1, " e ", N2);
END.
ALGORITMO IN C++
#include <iostream>
using namespace std;
int main()
{
int n1;
int n2;
int n3;
int n4;
int mcd;
int r;
int mcm;
cout<<"inserisci primo numero"<<endl; cin>>n1;
cout<<"inserisci secondo numero"<<endl; cin>>n2;
if(n2>n1)
{
r=n2;
n2=n1;
n1=r;
}
n3=n1;
n4=n2;
//Calcolo MCD
r = n3 % n4;
while(r!=0)
{
n3 = n4;
n4 = r;
r = n3 % n4;
}
mcd = n4;
//Calcolo mcm
mcm = (n1 * n2)/mcd;
cout<< "MCD = " << mcd << " mcm = " << mcm << endl;
cout<< "Numeri iniziali = " << n1 << " e " << n2 << endl;
system("pause");
}
I am really enjoying the theme/design of your website.
Do you ever run into any browser compatibility problems?
A number of my blog audience have complained
about my blog not working correctly in Explorer but looks great in Firefox.
Do you have any advice to help fix this issue?
Hello can you tell me the address of the site’s URL?
I loved as much as you will receive carried out right here.
The sketch is tasteful, your authored subject matter stylish.
nonetheless, you command get got an impatience over that you wish be
delivering the following. unwell unquestionably come further formerly again as exactly the
same nearly a lot often inside case you shield this hike.
I have been exploring for a bit for any high-quality articles or blog posts in this kind of space .
Exploring in Yahoo I eventually stumbled upon this web site.
Studying this information So i am satisfied to convey that
I have a very good uncanny feeling I found out just what I needed.
I such a lot definitely will make certain to do
not omit this web site and provides it a look on a relentless basis.
thank you so much.
I am now not positive where you’re getting your information, however great topic.
I must spend some time learning more or figuring
out more. Thank you for fantastic info I used to be in search of this info for my mission.
Thank you so much.
Thank you for the good writeup. It in fact was a amusement account it.
Look advanced to more added agreeable from you!
However, how could we communicate?
I think this is among the most important info for me.
And i am glad reading your article. But wanna remark on some general things, The
web site style is wonderful, the articles is really nice : D.
Good job, cheers
Do you mind if I quote a few of your articles
as long as I provide credit and sources back to
your webpage? My blog is in the exact same niche as yours and my
visitors would truly benefit from some of the information you present here.
Please let me know if this ok with you. Many thanks!
It is just good that enter the source of the article and a link that leads to my site.
Can you tell me the address of your website?