Created
November 30, 2016 02:52
-
-
Save dhanyn10/bd46277ede4f4487327f80fc00e673b7 to your computer and use it in GitHub Desktop.
Java - Program mencari faktor bilangan
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
import java.util.Scanner; | |
public class faktornya { | |
public static void main(String[] args) { | |
Scanner a = new Scanner(System. in ); | |
System.out.println("Masukkan angka"); | |
int nilai = a.nextInt(); | |
System.out.println("Faktor-faktornya:"); | |
int tambah = 0; | |
for (int z = 0; z <= nilai; z++) { | |
tambah++; | |
if (nilai % tambah == 0) { | |
System.out.print(tambah /* tampilkan bilangan ketika nilainya | |
* merupakan modulus dari nilai yang dicari | |
*/ | |
+ " "); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment