- 1

Unknown error in prime number

I don't know what is wrong with my code but When I input a small number like 12 I am get correct output but when I input 47 my code outputs // It is not prime It is prime Don't know what's wrong? https://code.sololearn.com/cqZn7sdusQup/?ref=app

1st Aug 2019, 2:58 PM
Shyamal Bhatt
Shyamal Bhatt - avatar
7 Answers
+ 3
I'm quite confused why are you doing modulo i%b instead of a%i in your code. If you do it a%i it returns correct result.
1st Aug 2019, 3:14 PM
Mateusz R
Mateusz R - avatar
+ 2
he needs that while loop, this code will fail in cases like 9. Just replace i%b with a%i.
1st Aug 2019, 3:22 PM
Mateusz R
Mateusz R - avatar
+ 2
Shyamal Bhatt he/she told you what was wrong with your code. He shouldnt have to spoonfeed you it. All you’re doing is changing 1 line.
1st Aug 2019, 3:24 PM
Ole113
Ole113 - avatar
0
n3v375 but what is wrong with my code
1st Aug 2019, 3:13 PM
Shyamal Bhatt
Shyamal Bhatt - avatar
0
As Ole mentioned I shouldn't do this, but here you go anyways https://code.sololearn.com/c4xfjN9kxfW0/?ref=app
1st Aug 2019, 5:34 PM
Mateusz R
Mateusz R - avatar
0
Mateusz R Thanks buddy 😎
2nd Aug 2019, 12:09 AM
Shyamal Bhatt
Shyamal Bhatt - avatar
- 2
Mateusz R Can u upload the correct version
1st Aug 2019, 3:17 PM
Shyamal Bhatt
Shyamal Bhatt - avatar