Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions GCD Recursion
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#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);

return 0;
}

int hcf(int n1, int n2)
{
if (n2 != 0)
return hcf(n2, n1 % n2);
else
return n1;
}