Write a PHP program to find the larger from two given integers. However if the two integers have the same remainder when divided by 7, then the return the smaller integer. If the two integers are the same, return 0
<?php function test($x, $y) { if ($x == $y) { return 0; } else if (($x % 7 == $y % 7 && $x < $y) || $x > $y) { return $x; } else { return $y; } } echo test(11, 21)."\n"; echo test(11, 20)."\n"; echo test(10, 10)."\n";
Sample Output:
21 20 0
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer