Add up 1 to 100 · اجمع من 1 إلى 100
Add up 1 to 100
Add every whole number from 1 to 100 and print the result.
This is a running total: start at 0 and add the loop variable on every pass. The starter adds 1 to 10, so you only need to change where the range stops. The young Carl Friedrich Gauss is said to have found this answer in his head by pairing 1 + 100, 2 + 99 and so on.
اجمع من 1 إلى 100
اجمع كل عدد صحيح من 1 إلى 100 وطبع النتيجة.
هذا مجموع تراكمي: ابدأ من 0 وأضف متغير الحلقة في كل دورة. المبدئ يضيف 1 إلى 10، لذا تحتاج فقط لتغيير مكان توقف range. يُقال إن كارل فريدريك غاوس الصغير وجد هذه الإجابة في ذهنه عن طريق مطابقة 1 + 100، 2 + 99 وما إلى ذلك.
Use a for loop to add up every whole number from 1 to 100, then print the total once. · استخدم حلقة for لجمع كل عدد صحيح من 1 إلى 100، ثم اطبع المجموع مرة واحدة.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.