Алгоритм Евклида
#include <iostream>
long int NOD(long int var1, long int var2)
{
while(var1 != var2)
if(var1 > var2)
std::swap(var1, var2);
var2 = var2 - var1;
}
return var1;
int main()
long int
A, B;
std::cin >> A >> B;
std::cout << "НОД(" << A << " и " << B << ") = " << NOD(A, B) << std::endl;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Алгоритм Евклида
#include <iostream>
long int NOD(long int var1, long int var2)
{
while(var1 != var2)
{
if(var1 > var2)
std::swap(var1, var2);
var2 = var2 - var1;
}
return var1;
}
int main()
{
long int
A, B;
std::cin >> A >> B;
std::cout << "НОД(" << A << " и " << B << ") = " << NOD(A, B) << std::endl;
}