Cody

# Problem 42749. Find the nearest prime

Solution 852849

Submitted on 18 Mar 2016 by HH
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
n = 3; y_correct = 3; assert(isequal(closestPrime(n),y_correct))

p = 2 3 5 y = 3

2   Pass
n = 20; y_correct = 23; assert(isequal(closestPrime(n),y_correct))

p = 2 3 5 7 11 13 17 19 23 29 31 37 y = 23

3   Pass
n = 86; y_correct = 89; assert(isequal(closestPrime(n),y_correct))

p = Columns 1 through 29 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 Columns 30 through 39 113 127 131 137 139 149 151 157 163 167 y = 89

4   Pass
n = 250; y_correct = 251; assert(isequal(closestPrime(n),y_correct))

p = Columns 1 through 29 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 Columns 30 through 58 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 Columns 59 through 87 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 Columns 88 through 95 457 461 463 467 479 487 491 499 y = 251