# Finding factors of a number

Hello. There is a table “slim”, in which 2 columns. The first is code, the second is cx. There is a page that has a \$_num variable that is equal to a certain number.

How to check if the number \$_num is divisible by all the numbers in the “cx” column without a remainder? It is solved through a cycle, but I can’t figure out how exactly. 8-(

Tell me how to write this.

## Answer 1, authority 100%

The algorithm is:

1. run a loop that iterates over all \$cx
2. values

3. divide in this loop \$_num % \$cx
4. if the result is not equal to 0 at least one result of division, we conclude that the number \$_num is not
divisible without remainder by all the numbers in
column cx

%in this case returns us the integer remainder of dividing \$_num by \$cx (i.e. 10 divided by 5 will return 0, and 10 divided by 9 will return 1).

The code is this:

``````   \$q = mysql_query("SELECT `cx` FROM `slim`");
while (\$d = mysql_fetch_assoc ( \$q ) )
{
extract ( \$d );
\$rest = \$_num % \$d['cx'];
if(\$rest!=0){\$symmary=1;}
}
if(\$symmary==1)
{
echo ' ';
}
else
{
echo '';
}
``````