Skip to content

Instantly share code, notes, and snippets.

@affandes
Created January 1, 2024 05:25
Contoh kode Faktorial menggunakan for
public class Faktorial {
public static void main(String[] args) {
int n = 5;
int hasil = 1;
for(int i = 1; i <= 5; i++) {
hasil = hasil * i;
}
System.out.println("Faktorial dari " + n + " adalah " + hasil);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment