Current location - Training Enrollment Network - Mathematics courses - Ask the expert to explain, this JAVA code is written for Yang Hui Triangle.
Ask the expert to explain, this JAVA code is written for Yang Hui Triangle.
Public static void main(String[] args) {

for(int I = 0; I< 10; i++) {

for(int j = 0; j & ltI+ 1; j++) {

int num = 1;

for(int k = 0; k & ltj; k++) {

num = num *(I-k)/(k+ 1);

}

system . out . print(" "+num+" ");

}

system . out . println();

}

}

/*

* First of all, talk about the principles of I-cycle and J-cycle. J's reason

* There are only a few columns, so you will find that if the current row is 5, then the column must be 5, for the sake of simple three.

* angular. When it comes to the end of the cycle from int num = 1 to k, a triangle originally has I and J.

* Cycle is completely sufficient. Adding an extra K cycle is to calculate all the columns in each row and get the sum. about

* num = num * (i-k)/(k+ 1) I think the author wrote this as required.

* The formula is completely a mathematical problem, so I need to know what the result of each line he requires.

* sample, I can analyze why he wrote such a formula, maybe some heroes can push it backwards, hehe my level.

* This is for reference only.

*

*/