Skip to content · ⁨Passer au contenu⁩

Add up 1 to 100 · ⁨Additionner de 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.

Français

Additionner de 1 à 100

Additionnez tous les nombres entiers de 1 à 100 et affichez le résultat.

C'est un total cumulé : commencez à 0 et ajoutez la variable de boucle à chaque passage. L'initialisation ajoute 1 à 10, vous n'avez donc qu'à changer où s'arrête le range. On dit que le jeune Carl Friedrich Gauss a trouvé cette réponse de tête en associant 1 + 100, 2 + 99, etc.

Log in or create account · ⁨Se connecter ou créer un compte⁩

IGCSE, A-Level & AP