Greatest common divisor · القاسم المشترك الأكبر
Greatest common divisor
The GCD of two numbers is the largest integer that divides both. Euclid's algorithm is beautifully short: while b isn't 0, replace the pair (a, b) with (b, a % b). When b reaches 0, a is the answer.
القاسم المشترك الأكبر
القاسم المشترك الأكبر لعددين هو أكبر عدد صحيح يقبل القسمة عليهما. خوارزمية إقليد قصيرة وجميلة: طالما b لا يساوي 0، استبدل الزوج (a, b) بـ (b, a % b). عندما يصل b إلى 0، يكون a هو الإجابة.
Complete int gcd(int a, int b) to return the greatest common divisor of a and b. Euclid's method: repeatedly replace (a, b) with (b, a % b) until b is 0. · أكمل int gcd(int a, int b) لإرجاع القاسم المشترك الأكبر لـ a و b. طريقة إقليد: استبدل (a, b) بشكل متكرر بـ (b, a % b) حتى يصبح b يساوي 0.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.