How to Find the Sum of an Array of Numbers in JavaScript. You can use the reduce() method to find or calculate the sum of an array of numbers. The idea is to consider every integer i from 1 to n and add it in the output and recur for remaining elements [i..n] with reduced sum (n-i). Java Program to find Sum of N Natural Numbers using For loop. Enjoyed this post? This sum of n numbers in c program allows the user to enter any integer value. We divide our number by 10 (and round down, using javaScript’s Math.floor() ) . Input: A number n obtained using prompt Output: A table of numbers from 1 to n and their squares Printing first 10 odd natural numbers using loop in C language - Duration: 12:48. Once you've defined the integer value of N, use the formula sum = (N × (N+1)) ÷ 2 to find the sum of all the integers between 1 and N! To run this applet, you first enter the number n you wish to have illustrated; space limitations require 0