Craig R Morton
asked on
Tricky question in practice PHP Zend Certification exam
I am currently studying towards my Zend PHP certification and have came across this question in my first practice exam:
What does the following function do, when passed two integer values for $p and $q?
The available answers are:
Loops infinitely
Switches the values of $p and $q
Determines if they are both even or odd
Determines the greatest common divisor between them
Any help appreciated,
Picco
Calculates the modulus between the two
What does the following function do, when passed two integer values for $p and $q?
The available answers are:
Loops infinitely
Switches the values of $p and $q
Determines if they are both even or odd
Determines the greatest common divisor between them
Any help appreciated,
Picco
Calculates the modulus between the two
<?php
function magic($p, $q) {
return ($q == 0)
? $p
: magic($q, $p % $q);
}
?>
Determines the GCD between them.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Answer is :
Determines the greatest common divisor between them
as said by others. you need to trace it manually.
Determines the greatest common divisor between them
as said by others. you need to trace it manually.
ASKER
excellent!!!