Hi everyone, i am very much a beginner in c++, so please bear with me, i needed to create a code that states the lowest common multiple of several numbers. So i was looking over the internet and i came across this solution. And i dont't really get why if i put the result of (start%div[i])==0, it won't function. Instead when i put (start%div[i])!=0 , it works just fine. Please help!
#include <iostream>
usingnamespace std;
main(){
unsignedint i;
unsignedlonglong start = 20;
constint div[9]={11,12,13,14,15,16,17,18,19};
bool notfound = true;
bool found;
int answer;
while (notfound){
found = false;
start += 20;
for (i=0 ; i < 9 ; i ++ ){
if (start%div[i]!=0){ //if i wanted to find the lowest common
found=true; //multiple wouldn't i make it equal to zero?
}
}
if (found){
continue;
}
answer = start;
cout << answer;
notfound = false;
}
}