/** * @author lautturi.com * Java example: calculate the product of 1 to n in java */ import java.util.*; public class Lautturi { public static void main(String[] args) { int n = 10; int product = 1; for (int i = 2; i <= n; ++i) { product *= i; } System.out.println("The product of 1..n is " + product); } }
output:
The product of 1..n is 3628800