Leaderboard
Showing:
LCM of given array elements
Basic Accuracy: 11.65% Submissions: 43 Points: 1

Given an array A[ ] of N numbers, your task is to find LCM of it modulo 1000000007

Example 1:

Input:
N = 4
A = {1 , 2 , 8 , 3}
Output:
24
Explanation:
LCM of the given array is 24.
24 % 1000000007 = 24

Example 2:

Input:
N = 2
A = {1 , 8}
Output:
8
Explanation:
LCM of the given array is 8.

Your Task:
You don't need to read input or print anything. Your task is to complete the function lcmOfArray() which takes an Integer N and an Array A as input and returns the answer.

Expected Time Complexity: O(N*log(N))
Expected Auxiliary Space: O(1)

Constraints:
1 <= N <= 105
1 <= A[i] <= 105

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

LCM of given array elements

Output Window