PHP Faktorial

Iseng ..

<?php
$number=8;
$total=1;
echo “$number! : “;
for($number; $number>0; $number-=1){
        $total = $total*$number;
        echo “$number”;
        if ($number>1){
                echo ” x “;
        }
        else{
                echo “”;
        }
        //echo “$total “;
}
echo ” = $total”;
echo “\n”;

Disini saya hanya ingin mencatat bahwa operasi break atau continue ternyata tidak melakukan shifting atau pemindahan operasi sub’for’ (dikembalikan ke first loop nya). Saya nya yg belum tau….

arr

tx

Advertisements

Tinggalkan pesan atau komentar

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s