Alright, from an article I tried to find the prime number and from my research I found a solution (which is not mine) and I need help on underestanding it.

Here is the code:

I have tried reading tutorials but it's of no use.. Can someone explain it to me?Code:#include<iostream> using namespace std; int main() { int num; cout<< "Enter a number "; cin >> num; int i=2; //why I set i to 2? while(i<=num-1) //why I must num-1??? { if(num%i==0) { cout << "\n" << num << " is not a prime number."; break; //breaks from where to where? } i++; //why the heck again I must add to i+1? } if(i==num) cout << "\n" << num << " is a prime number."; return 0; }