Lowest Common Multiple

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!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>

using namespace std;

main(){

unsigned int i;
unsigned long long start = 20;
const int 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;

}

}  
Your choice of name is very unfortunate. If you rename found to notCommonMultiple you will understand the logic immediately
Ah i get it. Sorry, thats what i get for blindly following examples. Many thanks.
Topic archived. No new replies allowed.