+ 1
I want to print only prime nos. Plz check.(it's printing required output but 2 2 times)
7 Respuestas
+ 1
Flag is always false...I do litle changes to your code, check it here:https://code.sololearn.com/cf0Jx2cbE4f3/?ref=app
+ 1
I got the same as Cristian Baeza Jimenez by changing the print line to be
if (i==num) System.out.println(num);
I didn't mess about with your unused flag.
+ 1
Sure mate, I literally only changed that line..
Edit: hold up, it doesn't work correctly!!! sorry.
EDIT2: fixed it, used the flag, moved the assignment of num, only check factors to half of i.
Do you see what I changed, and why??
https://code.sololearn.com/cHEG95rOFGwN/?ref=app
+ 1
K thx HungryTradie
0
Cristian Baeza Jimenez Thank u
0
HungryTradie can u share u soln plz.
0
Here another code originally from @GUMPERT https://code.sololearn.com/cWqsvh2kOTU4/?ref=app