Fizz Buzz dengan Java

Run Settings
LanguageJava
Language Version
Run Command
/** * Program : Fizz Buzz menggunakan Java * Date : 19 Juni 2022 * Author : Riyanto * Website : www.melonkoding.com */ class Main { public static void main(String[] args) { int n = 50; String m = null; for(int i = 1; i <= n; i++) { if((i % 3 == 0) && (i % 5 == 0)) { m = "Fizz Buzz"; } else if(i % 3 == 0) { m = "Fizz"; } else if(i % 5 == 0) { m = "Buzz"; } else { m = String.valueOf(i); } System.out.printf("%d. %s\n", i, m); } } }
Editor Settings
Theme
Key bindings
Full width
Lines