This is a program to find the least common multiple of numbers 1 to 20. I dont know why it doesnt work. Somebody please help me out

#include<iostream>
#include<conio.h>
#define A 100
using namespace std;
int i;
bool IsItDiv(int);
int main()
{   int num=21;bool tf;

    tf=IsItDiv(num);cout<<"The number thats divisible 

is";
    if(tf)
    cout<<"The number thats divisible is"<<num;
    else
    {num++;IsItDiv(num);}
    getch();
    
    }
bool IsItDiv(int n)
{
    for(i=1;i<=20;i++)
    {
        if((n%i)==0)
        {
            if(i==20)
            {return true;}
            else 
            {continue;}
            
        }
        else
        {
            return false;
        }
    }
}

(1) don't use conio.h

(2) do post your questions in the appropriate forum: this is C++ code, not C

What's an excited title for help request: I don't know!!...
Next time try to invent more sensible phrase...

It's a well-known ;) fact that

lcm(a,b) = (a/gcd(a,b))*b

where gcd means greatest common divisor.
Euclidian algorithm for computing gcd - see:
http://en.wikipedia.org/wiki/Euclidean_algorithm
It's so easy...

Don't use global variables in this simple (and others) program. For example, declare IsItDiv function with two parameters - n and i. However no need in this function in the recommended solution.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.