logo CodeStepByStep logo

factor_count

Language/Type: PHP parameters cumulative sum return

Write a function named factor_count that accepts an integer as its parameter and returns a count of its positive factors.

For example, the eight factors of 24 are 1, 2, 3, 4, 6, 8, 12, and 24, so the call of factor_count(24) should return 8. If passed a negative integer, your function should throw an Exception with the message, "Error: parameter value must be non-negative."

You may assume that the parameter passed is an Integer type.

Function: Write a PHP function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.