LightOJ 1289 LCM from 1 to n
Description
Given an integer n, you have to find lcm(1, 2, 3, …, n)
lcm means least common multiple. For example lcm(2, 5, 4) = 20,
lcm(3, 9) = 9, lcm(6, 8, 12) = 24.Input Input starts with an integer T (≤ 10000), denoting the number
of test cases. Each case starts with a line containing an integer n
(2 ≤ n ≤ 108).Output For each case, print the case number and lcm(1, 2, 3, …, n).
As the result can be very big, print the result modulo 232.Sample Input
5
10
5
200
15
20Sample Output
Case 1: 2520
Case 2: 60
Case 3: 2300527488
Case 4: 360360
Case 5: 232792560利用唯一分解定理可以得出一个有趣的递归式:
LCM(n+1)=LCM(n) |(n+1)不是一个素数p的方次,即p的k次方(k为正整数)
LCM(n)*p |反之
h