My professor has given a sequence of N numbers as a1, a2, ..., aN and asked me to find the smallest possible value of ai * aj such that it is a prime number, where 1 <= i < j <= N.
If it's possible to find any value of ai * aj such that it is a prime number, then print the smallest value of such ai * aj, otherwise print -1.
x=[1 2 3] y = 2
x=[5 5 5 2] y = -1
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers36
Suggested Problems
-
How to find the position of an element in a vector without using the find function
2819 Solvers
-
Increment a number, given its digits
688 Solvers
-
Permute diagonal and antidiagonal
513 Solvers
-
610 Solvers
-
07 - Common functions and indexing 4
423 Solvers
More from this Author2
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!