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.
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
- print"1"
- print "11"
- add 1 to myvariable
- Print "1"
- Print myvariable, myvariable times.
- Print "1"
- add 1 to myvariable
- repeat 4 - 7
- 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.
Nice toy. I'd ended up grabbing a Wemos D1 to test my scruffy code.
Stop before that breaks and doesn't
1 4 6 4 1
a7
Thanks a million my friend!!!!
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.