Skip to content

Instantly share code, notes, and snippets.

@meminuygur
Created November 11, 2016 10:00
Show Gist options
  • Save meminuygur/9cbccdb27db6922738461dc19c251256 to your computer and use it in GitHub Desktop.
Save meminuygur/9cbccdb27db6922738461dc19c251256 to your computer and use it in GitHub Desktop.
acayip bir çarpım isteğiydi
<?php
$a = array(
0 => 1,
1 => 9,
2 => 2,
3 => 7);
function solution($a){
$b = array();
foreach ($a as $k => $v) {
$c = 1;
foreach( $a as $x){
if( $v != $x) $c *= $x;
}
$b[] = $c;
}
return $b;
}
print_r(solution($a));
/* Return Result
Array
(
[0] => 126
[1] => 14
[2] => 63
[3] => 18
)
Return Result */
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment