خرید بک لینک
gameover.blog.ir

/* Example to calculate GCD or HCF using recursive function. */

#include <iostream>
using namespace std;
int hcf(int n1, int n2);
int main()
{
   int n1, n2;
   cout << "Enter two positive integers: ";
   cin >> n1 >> n2;
   cout << "H.C.F of " << n1 << " & " <<  n2 << " is: " << hcf(n1, n2);
   retu 0;
}
int hcf(int n1, int n2)
{
    if (n2!=0)
       retu hcf(n2, n1%n2);
    else 
       retu n1;
}

Output

Enter two positive integers: 366 60
H.C.F of 366 and 60 is: 6

برچسب: نویسنده: ایلیا حیدری تاريخ: شنبه 17 مهر 1395 ساعت: 2:14

صفحه بندی