0
Please find my error?
I wrote a code to find the next big prime number and print the distance between them. But it is only working till line 20. I don't understand what logic error or any other error is there preventing to print the output. Does anyone know? Please do tell me. https://code.sololearn.com/cxDr4U5OkU79/#c
2 Respuestas
+ 2
Here you go
https://code.sololearn.com/cseKfGc6p38K
0
I think that flag var MUST be initialized to 0 before the "prime checker loop" and not only if i is 2.... in mentioned loop you check if a number is a prime and set flag if it is not prime (set it to 1) but if it is, your flag i setted to last number (previous)and so on getting a infinite loop.... I repeat flag MUST setted to 0 before loop (for) and i think than you want do "i-n" in printing difference