Contact: aviboots(AT)netvision.net.il
39,926 questions
51,859 answers
573 users
// In mathematics, the natural numbers are 1, 2, 3, 4, and so on // 1 + 2 + 3 + 4 + ... + N let n = 10, sum = 0; while (n > 0) { sum += n; n--; } console.log("The sum is: " + sum); /* run: The sum is: 55 */
// In mathematics, the natural numbers are 1, 2, 3, 4, and so on // 1 + 2 + 3 + 4 + ... + N let n = 12, sum = 0; sum = n / 2 * (n + 1); console.log("The sum is: " + sum); /* run: The sum is: 78 */