How can I get the perfect numbers in arduino one?

hi again, i have another practice I can’t solve about generating the perfect numbers serie??

When is the assignment due to be handed in? What level of notes do you need added to the code? Is GOOGLE broken in your internet?

void setup() {
 
 Serial.begin(115200);
 
   int coef = 1, space, i, j;
   int rows = 10;
 
   for (i = 0; i < rows; i++) {
      for (space = 1; space <= rows - i; space++)
         Serial.print(" ");
 
      for (j = 0; j <= i; j++) {
         if (j == 0 || i == 0)
            coef = 1;
         else
            coef = coef * (i - j + 1) / j;
         Serial.print(coef);
         Serial.print(" ");
      }
 
      Serial.println();
   }
}

void loop() {


}

Best of luck getting an A+ grade.

1 Like

Ignoring the Arduino or coding for now, can you write on a piece of paper instructions to create the output you want?

For instance
myvarialbe = 1

  1. print"1"
  2. print “11”
  3. add 1 to myvariable
  4. Print “1”
  5. Print myvariable, myvariable times.
  6. Print “1”
  7. add 1 to myvariable
  8. repeat 4 - 7
  9. now define when to stop.

Wikipedia about Pascal’s triangle : https://en.wikipedia.org/wiki/Pascal%27s_triangle.

Sketch by @Dougie in Wokwi simulation : https://wokwi.com/arduino/projects/297728719332573705
Click to green start button to run, click the stop button to change the sketch.

1 Like

Nice toy. I’d ended up grabbing a Wemos D1 to test my scruffy code.

1 Like

Stop before that breaks and doesn’t

1 4 6 4 1

a7

Thanks a million my friend!!!