Last active
September 27, 2023 04:30
-
-
Save piharpi/a0647d18d8f49acf89349bcddcc4df7c to your computer and use it in GitHub Desktop.
PHP Mencari Bilangan Genap
This file contains 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 | |
# Clue : Karena syarat bilangan genap yaitu jika bilangan itu di bagi 2 sisa 0. | |
for ($x=1; $x <= 10; $x++){ // Mengulang selama 10 kali yang di mulai dari angka 1 | |
if ( $x % 2 == 0 ){ // Mengecek apakah bilangan itu dibagi 2 sisa 0 | |
echo " ".$x; // Jika benar bilangan itu di bagi 2 sisa 0 maka menampilkan bilangan itu, yang dipisahkan oleh string kosong | |
} | |
} | |
# Hasil : 2 4 6 8 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment