Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- static Scanner inputScanner = new Scanner(System.in); // Static object of the Scanner class.
- public static void main(String[] args) {
- int
- minimumValue = inputScanner.nextInt(), // Input the minimum value of the range.
- maximumValue = inputScanner.nextInt(); // Input the maximum value of the range.
- String tempString = new String(); // Object of the string class for temporary storage.
- // The for loop range:
- for (int nIteration = minimumValue; nIteration <= maximumValue; nIteration++) {
- tempString = String.format("%d :", nIteration); // The number of the iteration.
- for (int nRange = 2; nRange < nIteration; nRange++) {
- if (nIteration % nRange == 0) // If the remainder of the division is zero:
- tempString += String.format(" %d", nRange); // Adding to the string.
- }
- System.out.println(tempString); // Output.
- }
- tempString = null; // Freeing an object of the class.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement