// Product.java // Bob Myers // // A typical kind of for-loop algorithm -- multiplying things import java.util.Scanner; class Product { public static void main(String[] args) { Scanner s = new Scanner(System.in); int value; System.out.print("Enter an integer: "); value = s.nextInt(); long product = 1; // initialize an accumulator variable int i; for (i = 1; i <= value; i++) { if (i % 5 == 0) // if the index is divisible by 5 product = product * i; // multiply it in to the accumulator } System.out.println("In the range 1 through " + value + ",\n\tthe product of the numbers that are divisible by 5 = " + product); } }