Created
July 13, 2012 07:49
-
-
Save hidayat365/3103450 to your computer and use it in GitHub Desktop.
Problem Deret v2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// looping terluar untuk menghitung | |
// angka dari 1 sampai 100 dengan increment 4 | |
for ($i=1; $i<=100; $i+=4) { | |
// looping dalam untuk menampilkan tiap baris angka | |
// masing2 baris angka terdiri dari empat bilangan | |
for ($j=0; $j<4; $j++) { | |
// cetak angkanya | |
print $i+$j.' '; | |
// cetak hurufnya, logikanya | |
// huruf dicetak saat sisa modulus 4 counter loop dalam bersisa 0 atau 3 | |
// kemudian, | |
// cetak huhuf 'a' jika modulus 8 counter loop luar kurang dari 4 | |
// cetak huruf 'b' jika modulus 8 counter loop luar lebih dari atau sama dengan 4 | |
if ($j%4==0 or $j%4==3) print $i%8<4 ? 'a ' : 'b '; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment