- 1

Why does it not show the number 2? 2 is prime.

https://code.sololearn.com/c090h5NAX62Q/?ref=app

21st Oct 2020, 7:14 AM
Ahmad
6 Answers
+ 3
Because for "i = 2" the condition in if statement (that is 2%2==0 now) will be true and the loop will break on it's first iteration
21st Oct 2020, 7:26 AM
Arsenic
Arsenic - avatar
+ 2
Adding an extra condition for n == 2 will work here👇 https://code.sololearn.com/cneIxJCx35BH/?ref=app
21st Oct 2020, 7:32 AM
Arsenic
Arsenic - avatar
+ 1
Thanks
21st Oct 2020, 7:34 AM
Ahmad
+ 1
Ahmad you're welcome 🙂
21st Oct 2020, 7:35 AM
Arsenic
Arsenic - avatar
0
What is the solution for show 2?
21st Oct 2020, 7:27 AM
Ahmad
0
I just started learning, thanks for the help
21st Oct 2020, 7:28 AM
Ahmad