LCM of Primes
InterviewTime limit1sMemory limit512 MB
Given a sequence of N numbers, take the prime values among them and print their least common multiple, or -1 if none are prime.
- Level
Medium4 of 10
- Topics
- Number theory, Math, Implementation, Brute force
- Solved
- No attempts yet
Problem
Happi wants to pick out the primes in a sequence of length and find their least common multiple.
Help Happi compute this value.
Input
The first line gives the length of the sequence .
The next line gives the elements of , separated by spaces.
Only inputs whose answer is less than are given.
Output
Print the least common multiple of the primes on the first line.
If there are no primes, print -1.