GCD + LCM

Given the value of N, you will have to find the number of digits in G and L in base googol (10100). The definition of G and L are given below: N−1 N ∏∏ ∏∏ G = If you are not accustomed with the symbol , then for your kind information we give an example: 4−1 4 ∏∏ GCD(i, j) = GCD(1, 2) ∗ GCD(1, 3) ∗ GCD(1, 4) ∗ GCD(2, 3) ∗ GCD(2, 4) ∗ GCD(3, 4) Here GCD(i,j) means the greatest common divisor of integer i and integer j, and LCM(i,j) means the Least Common Multiplicand of integer i and integer j. Input The input file contains at most 100 lines of inputs. Each line contains an integer N (1 < N < 1000001). Input is terminated by a line containing a single zero. Output For each line of input produce one line of output. This line contains the serial of output followed by two integers DG and DL. Here DG is the number of digits in G when written in base googol and DL is the number of digits in L when written in base googol. Don’t even think of submitting a brute force solution: It will probably take more than 2 years for the largest possible input. Look at the output for sample input for format details. Sample Input 10 100 20000 0 Sample Output Case 1: 1 1 Case 2: 11 146 Case 3: 494294 14972385 i=1 j=i+1 i=1 j=i+1 GCD(i,j) ∏ L = LCM(i,j) N−1 N i=1 j=i+1