PHP Challenge 4 - Check if a Number is a Factor of Another Number

phplogo.jpg

This fairly simply challenge involves quite a powerful little test which you may find yourself using on a regular basis.

The idea is to allow the user to enter 2 numbers. Create a simple form to allow the user to input the numbers. 

After validating the input you will then check if the first number is a factor of the second number.

Print out a suitable message to the user.

For example, if the user enters 5 and 20 then we need to test if 5 is a factor of 20.

WHAT IS A FACTOR?

A factor is a number (there are other factor types) that will divide exactly into another number without leaving a remainder.

In the case of our example, if we take 20 and divide by 5 then we get 4 and no remainder. Therefore, 5 is a factor of 20.

Other factors of 20 are: 1, 2, 4, 5, 10, 20

Would you like the solution to this challenge?

The full video solution together with downloadable code is available in the PHP for Beginners course.

This course is taught by Patrick Morrow, a national award-winning teacher, who is very active in the course and who provides full support.

To enrol in the course click here.