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 หยุด.卡尔ฟรี德里希高斯 (Carl Friedrich Gauss) ในวัยเด็ก reportedly พบคำตอบนี้ในใจโดยการจับคู่ 1 + 100, 2 + 99 และอื่นๆ

Log in or create account · ⁨เข้าสู่ระบบหรือสร้างบัญชี⁩

IGCSE, A-Level & AP