#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

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

edited September 2015

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:

``````   *
**
***
****
``````

format the code right

http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text#latest

is this homework?

• your code does't run - you need `int n=10;`

• ``````   *
**
***
****
``````
• do you mean that?

• edited September 2015 Answer ✓

your sketch (if it would work, insert the line with n)

let's say n is 10 and you want to see a graphic for n=10

``````int k=0;

while-loop with i, increment i

have a for loop with y from 0 to i

ellipse ( i*20 , y*20 , 13, 13) ;
k++;

when the k up to now is = n quit the while-loop
``````
• edited September 2015

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:

``````   *
**
***
****
``````
• yes, see my pseudo code above.

• can you write a sketch, starting with my pseudo-code?

• Yes, I am doing. Thank you.