নিচের কোডটি এক্সটেন্ডেড ইউক্লিডের কোড। রিকার্সন ইউজ করে করা হয়েছে। আমি ইটারেটিভ ফর্মটা বুঝলে এটা কোনোভাবেই বুঝতেছি না। যদি কেউ,একটু হেল্প করতেন,তাহোলে খুব উপকার হতো।

#include < iostream >
int d, x, y;
void extendedEuclid(int A, int B) {
if(B == 0) {
    d = A;
    x = 1;
    y = 0;
}
else {
    extendedEuclid(B, A%B);
    int temp = x;
    x = y;
    y = temp - (A/B)*y;
}
}
 int main( ) {
 extendedEuclid(16, 10);
 cout << ”The GCD of 16 and 10 is ” << d << endl;
 cout << ”Coefficient x and y are: ”<< x <<  “and  “ << y << endl;
 return 0;   
}
This question is marked "community wiki".

asked 28 Feb '16, 16:40

sshuvo's gravatar image

sshuvo
15411

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×33
×6

question asked: 28 Feb '16, 16:40

question was seen: 679 times

last updated: 28 Feb '16, 16:40