Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FactorsofIntegers {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.print("Enter an Integer:");
- int number1;
- //User must enter an integer
- number1 = input.nextInt();
- //Display all the integers in increasing order
- System.out.println("The factors for this integer are:");
- for ( int factor = 2; factor < number1; factor ++){
- if (number1 % factor == 0) {
- System.out.print(factor + ", ");
- }
- }
- System.out.printf(".");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement