Java get the factors of a number

h‮ptt‬s://www.lautturi.com
Java get the factors of a number
/**
 * @author lautturi.com
 * Java example: find out all factors of a number in java
 */

import java.util.*;

public class Lautturi {

	public static void main(String[] args) {

		int number = 20;

		System.out.print("Factors of " + number + " are: ");
		for (int i = 1; i <= number; ++i) {
			if (number % i == 0) {
				System.out.print(i + " ");
			}
		}
	}
}

output:

Factors of 20 are: 1 2 4 5 10 20
Created Time:2017-09-05 14:49:45  Author:lautturi