Can someone explain this answer? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
14th Oct 2019, 7:13 AM
Joe Carbon
Joe Carbon - avatar
1 Answer
+ 1
Let the way for the level 3 guy 😌😂 You demand to print k ,which has a last value of k*n .and this precedent k=1 ,while n is in the interval :[1,2,3,4] So k=k*n =1*1 and then the new k(0)=1 too.. The loop repeat the operation with every new value of n : K(1)=k(0)*2=2 K (2)=k (1)*3=6 K (3)=k (2)*4=24 (the end of while loop) Your code is: n=1 k=1 while n <=4: k *=n n +=1 print(k)
14th Oct 2019, 11:32 AM
Epss -éducation
Epss -éducation - avatar