Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function maximumProduct($a){
- $i = 0; $j = 0; $max = 0; $tamanho = count($a);
- for($i = 0; $i < $tamanho; $i++){
- for($j = $i+1; $j < $tamanho; $j++){
- if($a[$i]*$a[$j] > $max && (($a[$i]*$a[$j]) % 3 === 0)){
- $max = $a[$i]*$a[$j];
- }
- }
- }
- return $max;
- }
- $arr1 = array(6,8,8,7,2,5);
- echo maximumProduct($arr1);
- $arr2 = array(1,9,2,4);
- echo maximumProduct($arr2);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement