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

Add up 1 to 100 · ⁨חיבור 1 עד 100⁩

English

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 וכו'.

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

IGCSE, A-Level & AP