Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     static Scanner inputScanner = new Scanner(System.in); // Static object of the Scanner class.
  6.    
  7.     public static void main(String[] args) {
  8.  
  9.         int
  10.             minimumValue = inputScanner.nextInt(), // Input the minimum value of the range.
  11.             maximumValue = inputScanner.nextInt(); // Input the maximum value of the range.
  12.        
  13.         String tempString = new String(); // Object of the string class for temporary storage.
  14.        
  15.         // The for loop range:
  16.        
  17.         for (int nIteration = minimumValue; nIteration <= maximumValue; nIteration++) {
  18.            
  19.             tempString = String.format("%d :", nIteration); // The number of the iteration.
  20.            
  21.             for (int nRange = 2; nRange < nIteration; nRange++) {
  22.                
  23.                 if (nIteration % nRange == 0) // If the remainder of the division is zero:
  24.                     tempString += String.format(" %d", nRange); // Adding to the string.
  25.                
  26.             }
  27.            
  28.             System.out.println(tempString); // Output.
  29.            
  30.         }
  31.        
  32.         tempString = null; // Freeing an object of the class.
  33.  
  34.     }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement