I need to write a program that enters a number and displays the highest divisor, and then the senior divisor of the divisor, etc., until it reaches a prime. But I continue: "Unhandled exception at 0x00eb1504 in the primefinder.exe file: 0xC0000094: integer division by zero."
I assume that his "num% i" calls it, but "i" cannot be zero since its "num / 2".
#include <iostream>
using namespace std;
int main(){
unsigned int i=666, num;
cout << "Enter number";
cin >> num;
while(i>1){
i = num/2;
while(num % i == 0){
i--;
}
cout << i << endl;
num=i;
}
cin.get();
return 0;
}
source
share