Java program to find factors of any number
public class Main {
public static void main(String[] args) {
// Factors of 6 : 1,2,3,6
// Factors of 10 : 1,2,5,10
int num = 45;
System.out.println("Factors of " + num + " : ");
for(int i=1; i<=num; i++) {
if(num % i == 0) {
System.out.println(i + " ");
}
}
}
}