Monday, August 18, 2025

GCD

 #include <iostream>

 using namespace std;
 void gcd(int n1,int n2){
    int gcd;
   while(n1>0&&n2>0){
    if(n1>n2)n1=n1%n2;
    else n2=n2%n1;
   }
   if(n1==0)gcd=n2;
   gcd=n1;
   cout<<gcd<<endl;
 }
 int main() {
 //Write your C++ code here
 cout << "Hello, World!" << endl;
 gcd(6,12);
 return 0;
 }

No comments:

Post a Comment

MergeSort

  #include < iostream >   using namespace std ;   void merge ( vector < int >& n , int low , int mid , int high ){   ...