+ 1
What is the warning in this code?
This code is about calculating prime number by using function but it has a warning... i don't know what it is https://code.sololearn.com/cI9HS2OAaf97/?ref=app
5 Respuestas
+ 3
Fatemeh
What if your loop and if block doesn't execute then your function will not return anything which should return because return type is int so you should return 0 after end of for loop
+ 2
A͢J Thank u so much
+ 2
Fatemeh
Your program will always return true because of (i < n && c == 0) and if(c == 0)
+ 2
A͢J Yes... you are true
+ 1
Also the logic is not true. You cannot find prime number in this way.
To find a prime number, we have to check if that number is perfectly divisible by any integers between 2 and the root of our number. If it is perfectly divisible even by 1 number , it is not prime.
https://code.sololearn.com/cNQa8jPCopGv/?ref=app