Skip to content · ⁨דלג לתוכן⁩

Greatest common divisor · ⁨מחלק משותף גדול ביותר⁩

English

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.

עברית

מחלק משותף גדול ביותר

ה-MCD של שני מספרים הוא השלם הגדול ביותר המחלק את שניהם. אלגוריתם אוקליד קצר ומרהיב: כל עוד b אינו 0, החלף את הזוג (a, b) עם (b, a % b). כאשר b מגיע ל0, a היא התשובה.

Log in or create account · ⁨היכנס או צור חשבון⁩

IGCSE, A-Level & AP