Skip to content · ⁨الانتقال إلى المحتوى⁩

Digital root · ⁨الجذر الرقمي⁩

English

Digital root

Keep adding digits until a single digit remains.

Two loops work together here. The inner for adds up the digits once; str(n) lets you loop over them as characters. The outer while repeats that as long as the number still has two or more digits, which is while n >= 10.

العربية

الجذر الرقمي

استمر في جمع الأرقام حتى يتبقى رقم واحد.

تعمل حلقتان معاً هنا. تحتوي الحلقة الداخلية for على جمع الأرقام مرة واحدة؛ permitting str(n) لك التجول فوقها كحروف. الحلقة الخارجية while تكرر ذلك طالما لا يزال الرقم يحتوي على رقمين أو أكثر، وهو بينما n >= 10.

Log in or create account · ⁨تسجيل الدخول أو إنشاء حساب⁩

IGCSE, A-Level & AP