Problem 981. Find nearest prime number less than input number
Solution Stats
Problem Comments
-
6 Comments
Show
3 older comments
@bmtran (Bryant Tran)
on 10 Oct 2012
1 isn't a prime number
Disha
on 31 Jul 2013
agree @bmtran...
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:
https://en.wikipedia.org/wiki/Fundamental_theorem_of_arithmetic
https://en.wikipedia.org/wiki/Prime_number#Primality_of_one
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 Comments
Show commentsProblem Recent Solvers607
Suggested Problems
-
321 Solvers
-
336 Solvers
-
Find the next Fibonacci number
436 Solvers
-
2913 Solvers
-
788 Solvers
More from this Author11
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!