Problem 981. Find nearest prime number less than input number
30.42% Correct | 69.58% Incorrect
Last Solution submitted on May 27, 2023
Show 3 older comments
@bmtran (Bryant Tran) on 10 Oct 2012
1 isn't a prime number
Disha on 31 Jul 2013
Grzegorz Knor on 20 Sep 2013
You should correct the test suite. 1 isn't a prime number.
Vishal on 6 Oct 2014
Correct the test suite 1 is not prime number.
Daniel Pereira on 6 May 2016
1 is not a prime number, in order to fulfill with the fundamental theorem of arithmetic:
John D'Errico on 22 Feb 2018
I removed the test case where n==2, since 1 is indeed not a prime number. I also added a random test case, so the problem is not so easily cooked by knowing all the test cases.
Solution CommentsShow comments
Problem Recent Solvers607
Find the next Fibonacci number
More from this Author11
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!