+ 1
Explain solution
https://sololearn.com/compiler-playground/cZlm3IzN1oFj/?ref=app Question: int f=1, int i=2; While (++i>2){ f*=i; if(f>=20){ i/=2; f+=1; } } System.out.println(f); At first while(2+1>2) that's true and it countines Second f= 1* 2=2. 2+ :printLN If (f >=20) i=20 / 2= 10. Third f+=1 : [ f= 1+ (1 to 10)] 2+4+5+6+7+8+9+10+11:printLN f = 2 + ( i=3 + i=4 + i=5 + i=6 + i=7 + i=8 + i=9 + i=10 + (i=10 + 1). https://sololearn.com/compiler-playground/cZlm3IzN1oFj/?ref=app
13 Respostas
+ 1
the code do:
1*3
3*4
12*5
int( 5/2)
60+2
EDIT:
after code has changed from f+=i to f+=1 result is
60+1
+ 1
https://www.sololearn.com/discuss/3259120/?ref=app
https://www.sololearn.com/discuss/3259152/?ref=app
https://www.sololearn.com/discuss/3259091/?ref=app
https://www.sololearn.com/discuss/3259222/?ref=app
https://www.sololearn.com/discuss/3259128/?ref=app
https://www.sololearn.com/discuss/3259291/?ref=app
https://www.sololearn.com/discuss/3259163/?ref=app
https://www.sololearn.com/discuss/3259101/?ref=app
https://www.sololearn.com/discuss/3259357/?ref=app
https://www.sololearn.com/discuss/3259228/?ref=app
https://www.sololearn.com/discuss/3259388/?ref=app
https://www.sololearn.com/discuss/3259134/?ref=app
https://www.sololearn.com/discuss/3259267/?ref=app
https://www.sololearn.com/discuss/3259173/?ref=app
https://www.sololearn.com/discuss/3259204/?ref=app
https://www.sololearn.com/discuss/3259175/?ref=app
https://www.sololearn.com/discuss/3259177/?ref=app
https://www.sololearn.com/discuss/3259179/?ref=app
https://www.sololearn.com/discuss/3259149/?ref=app
http
0
https://sololearn.com/compiler-playground/cRbDhnwmK3qK/?ref=app
https://sololearn.com/compiler-playground/cq2qPnEvETuS/?ref=app
https://sololearn.com/compiler-playground/cw3yLjg0gsW2/?ref=app
https://sololearn.com/compiler-playground/cLThC97348sk/?ref=app
https://sololearn.com/compiler-playground/cXUb5QxnhUIf/?ref=app
https://sololearn.com/compiler-playground/c2KmFY70SZmP/?ref=app
https://sololearn.com/compiler-playground/cu7RgAUX0GUo/?ref=app
0
https://sololearn.com/compiler-playground/cYJ1bDg62KOE/?ref=app
https://sololearn.com/compiler-playground/cWWuy0PwiCML/?ref=app
https://sololearn.com/compiler-playground/cg7kiMwe6cG3/?ref=app
https://sololearn.com/compiler-playground/cASl2ZLKD4SV/?ref=app
0
And what happened for last function f+=1? ! (62 +1)
0
last operation is f+=i where f=60 and i =2
0
It was typed f+=1 and this 60+1 not 2
0
That's 1 not i=2
0
I see, you mean code after "Question:" not in the playground
0
The most important point in this code it typed: f*=i : 1*2 and again it returns to i/=2 while it's after
if (f>=20).
0
Your answer best answer but at last it gets 61 which that's true ,but 62 is not.
0
(60+1) and The end
0
but why there is break ?