Selasa, 10 September 2013

PHP Indonesia - Facebook: NEed Help Can any one make LCM prrogram in PHP ?

PHP Indonesia - Facebook
PHP Indonesia is a community for everyone that loves PHP. Our focus is in the PHP world but our topics encompass the entire LAMP stack. Topics include PHP coding, to memcached handling, db optimizations, server stack, web server tuning, code deploying, hosting options and much much more. Youtube Channel : http://www.youtube.com/user/OurPHPIndonesia Twitter : @php_indonesia NOTE: Rules for Wall posting: https://www.facebook.com/groups/35688476100/doc/10151597056316101/ Daftar Keanggotaan : http://www.facebook.com/groups/35688476100/doc/10150671770741101/ 
LSAT prep from HLS-educated instructors

LSATMax includes video lessons, unlimited personal attention & support, and over 6,000 real questions from previous LSAT's. Enroll for just $299.
From our sponsors
NEed Help Can any one make LCM prrogram in PHP ?
Sep 3rd 2013, 13:26, by ĦüRtéd ǷwIncḗ

ĦüRtéd ǷwIncḗ 1:26pm Sep 3
NEed Help
Can any one make LCM prrogram in PHP ?

Gunawan Mujur Wibisono 1:28pm Sep 3
lcm? what is lcm??

ĦüRtéd ǷwIncḗ 1:28pm Sep 3
least common multiple

Gunawan Mujur Wibisono 1:32pm Sep 3
like what?

Remo Harsono 1:36pm Sep 3
.
function lcm_arr($items){
//Input: An Array of numbers
//Output: The LCM of the numbers
while(2 <= count($items)){
array_push($items, lcm(array_shift($items), array_shift($items)));
}
return reset($items);
}

function gcd($n, $m) {
$n=abs($n); $m=abs($m);
if ($n==0 and $m==0)
return 1; //avoid infinite recursion
if ($n==$m and $n>=1)
return $n;
return $m<$n?gcd($n-$m,$n):gcd($n,$m-$n);
}

function lcm($n, $m) {
return $m * ($n/gcd($n,$m));
}

not yet tested, but seems ok

Al Ghurahy 2:06pm Sep 3
use the concept lcm & gcd calculation using prime numbers. breakdown into prime number factors

Al Ghurahy 3:01pm Sep 3
120 = 2³ * 3 * 5
126 = 2 * 3² * 7

lcm = 2³ * 3² * 5 * 7
(all prime factors, use biggest power)

gcd = 2 * 3
(only common factors, use lowest power)

# cara tusuk sate :v

Al Ghurahy 3:04pm Sep 3
nostalgia pelajaran SD, tp usefull bgt, pernah pake buat program hitung waris utk penyederhanaan pembagian.

Al Ghurahy 4:22pm Sep 10
sept 10th '13:

ternyata pemikiran saya diatas termasuk cara yg amat fool..
ada namanya algoritma euclid utk mencari gcd dan lcm yg sangat ninja! sperti berikut:

function gcd($a, $b) {
if($b == 0) return a;
else return gcd($a, $a % $b);
}

function lcm($a, $b) {
return $a * $b / gcd($a, $b);
}

haha cuman 2 bait = 7 baris

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions

Tidak ada komentar:

Posting Komentar