23rd Apr 2019, 8:56 AM
Na'vi Srivamsi
Na'vi Srivamsi - avatar
7 odpowiedzi
+ 6
Result is assumed to be 1 so initially when you do: result*=x You get the number you passed earlier in the method as first argument so that result is equal to x. result*=x ===> x result = x Then the for loop multiply that number with itself doing: result*=x ===> x*x result = x*x result*=x ===> x*x*x result = x*x*x ...
23rd Apr 2019, 9:06 AM
Maz
Maz - avatar
+ 5
There is a method called "Pow" which takes two arguments, a base and eventually an exponent (of none is given, 2 is assumed to be the exponent) The main method just checks the method and the output is the result of: 6^2=36 3^4=81
23rd Apr 2019, 9:02 AM
Maz
Maz - avatar
0
But in the code we mentioned result*=x;
23rd Apr 2019, 9:03 AM
Na'vi Srivamsi
Na'vi Srivamsi - avatar
0
For which I think the result should be 1*6 = 6
23rd Apr 2019, 9:04 AM
Na'vi Srivamsi
Na'vi Srivamsi - avatar
0
Ok, thank u
23rd Apr 2019, 9:07 AM
Na'vi Srivamsi
Na'vi Srivamsi - avatar
0
Hi
3rd May 2019, 8:16 AM
Neba Stanley
Neba Stanley - avatar
0
Hello
3rd May 2019, 8:17 AM
Neba Stanley
Neba Stanley - avatar