// Find first factor of a number (other than 1) // Try factors starting with 2 until we find one // that divides the number evenly import java.util.*; public class Factor { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("Enter a number: "); int number = console.nextInt(); int i = 2; while ( (number%i) != 0) { i = i + 1; } System.out.println("The first factor is " + i); } }