any one please explain me the below code please step by step
Below code prints prime number but i want to know why factors (variable) has 1 and 2 and then 3 and 4 value in last as its intial vale is 0 then factors++ increase its value by 1 so its final value must be 1... please explain me thank u ----------------------------------------------------------------------------------- #include <iostream> using namespace std; int main() { cout<<"2 is prime"<<endl;/*my code skips even numbers to make it faster so i had to manualy output the only even prime number*/ int num=1; while (num < 110){// change for more int factors = 0; num++; if(num%2==0){ num++; } for(int i =1; i<=num; i+=2){ if (num%i==0){ factors++; cout << "factor value " << factors << endl; // just to show value of factors } } if (factors == 2){ cout<<num<<" is prime"<<endl; } } return 0; }