Can you please go through the code its not printing output

bool prime_num(int n){
for(int i=2;i<=n;i++){
if(n%i==0){
return false;
}
}
return true;
}
in this function
for(int i=2;i<=n;i++){
when i=n then n%n=0 which is always true hence it always return false hence no printing anything
you can write is as: for(int i=2;i<n;i++){
but it is not perfect
ideally we have to go till sqrt(n)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.