原題鏈接
import java.util.Scanner; import java.math.BigInteger; public class Main{ public static void main(String[] args){ Scanner cin = new Scanner(System.in); int n, i; BigInteger[] prime = new BigInteger[101]; prime[1] = BigInteger.ONE; for(i = 2; i <= 100; ++i) prime[i] = prime[i - 1].multiply(BigInteger.valueOf(i)).divide(prime[i - 1].gcd(BigInteger.valueOf(i))); while(cin.hasNext()){ n = cin.nextInt(); System.out.println(prime[n]); } } }