Thanks Write function that returns the LCM of a list of numb

Thanks.

Write function that returns the LCM of a list of numbers. The function has 1 parameter - a list of integers - and return a number - the LCM of the numbers in the list.

Solution

int LCM(list<int> intList)
{
int listLCM;
int i=2;
while(true)
{
boolean flag=true;
for (std::list<int>::const_iterator iterator = intList.begin(), end = intList.end(); iterator != end; ++iterator)
{
std::cout << *iterator;
if(!(i%*iterator==0))
{
flag=false;
break;
}
}
if(flag==true)
{
listLCM=i;
break;
}
i++;
}
return listLCM;
}

Thanks. Write function that returns the LCM of a list of numbers. The function has 1 parameter - a list of integers - and return a number - the LCM of the numbe

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site