Mencari N Bilangan

Run Settings
LanguageJava
Language Version
Run Command
/** * Program : Menampilkan N bilangan ganjil/genap * Date : 6 Juni 2022 * Author : Riyanto * Website : https://www.melonkoding.com */ class Main { public static void main(String[] args) { // ubah nilai N untuk menentukan banyaknya bilangan genap/ganjil int n = 5; System.out.printf("%d bilangan genap:\n", n); for(int i = 1; i <= n * 2; i++) { // genap if(i % 2 == 0) System.out.printf("%d ", i); // ganjil //if(i % 2 == 1) System.out.printf("%d ", i); } } }
Editor Settings
Theme
Key bindings
Full width
Lines