The n-th triangular number can be obtained with Gauss' formula, the formula bears the name of the mathematician for a mere matter of historical convention but, according to the canons of priority assignment in use in mathematics, given its simplicity and the antiquity of the subject, it should certainly be attributed to others
The n-th triangular number can be obtained with Gauss' formula, the formula bears the name of the mathematician for a mere matter of historical convention but, according to the canons of priority assignment in use in mathematics, given its simplicity and the antiquity of the subject, it should certainly be attributed to others: here is the JAVA code to insert triangular numbers into an array of integers insert the java code into an editor like netbeans in the main.
package triangolari; public class Triangolari { public static void main(String[] args) { int triangolari[]= new int[100]; inizializzaArrayConTriangolari(triangolari); } public static int GetTriangolare(int n) { return (n*(n+1))/2; } public static void inizializzaArrayConTriangolari(int a[]) { for(int i=0;i<a.length;i++) { a[i]=GetTriangolare(i); System.out.println(a[i]); } } }
Follows the Java code to graphically draw the triangular numbers. here is the reference site on numerical sequences http://oeis.org/A000217