How to graph a triangular number? // Cómo graficar un número triangular?

kodkod
edited September 2015 in Hello Processing

Hello! // Hola! I need help, I do not know how to plot the nth triangular number. Here is my code. // Necesito ayuda, no sé cómo graficar el número triangular enésimo. Aquí esta mi código.

 void nesimotermino(int n){
 println((n*(n+1))/2);
}

 void nterminos(int n){
 int [] array=new int[n+1];
 for(int i=0;i<n+1;i++){
 array[i]=((i*(i+1))/2);
 }
 printArray(array);}

 void setup(){
   println("N-esimo termino de los numeros triangulares");
   nesimotermino(n); //replaced by any number n
   println("N primeros terminos de los numeros triangulares");
   nterminos(n); // replaced by any number n
   size(700,700);
 }
  void draw (){
   background(550); 
   strokeWeight(4);
   rectMode(CENTER); //(valor por defecto)
   ellipse(350,350,50,50);
   }

Thanks!! // Gracias

Excuse me. I want to know how to graph any triangular number that is replaced in the console as n. I'm a little confused about where to start. One could draw graph the number as follows:

   *
  **
 ***
****

Answers

Sign In or Register to comment.