Spring 2018 1 Finding the Factors of an Integer 25 pts Write
Spring 2018 1. Finding the Factors of an Integer (25 pts) Write a program that reads an integer and displays all its smallest factors. For example, if the input integer is 120, the output should be: 2, 2, 2, 3, 5, as shown below: Enter a positive integer: 120 he Factora for 128 is Press any key to continue The program will be named using your first and last name, such as \"JohnSmith 1.cpp
Solution
public static void main(String[] args) Scanner input = new Scanner(System.in); System.out.print(\"Enter first integer number: \"); int num = input.nextInt(); input.close(); for (int i = 2; i <= num;) { if (num % i == 0) { System.out.print(i + \" \"); num /= i; } else { i++; } } }