Cody

# Problem 60. The Goldbach Conjecture

Solution 1207388

Submitted on 7 Jun 2017 by Augusto Mazzei
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
nList = 28:6:76; for i = 1:length(nList) n = nList(i); [p1,p2] = goldbach(n) assert(isprime(p1) && isprime(p2) && (p1+p2==n)); end

p2 = 3 5 7 9 p1 = 5 p2 = 23 p1 = 5 p2 = 23 p2 = 2 3 5 7 9 10 11 p1 = 3 p2 = 31 p1 = 3 p2 = 31 p2 = 2 5 7 9 10 12 p1 = 3 p2 = 37 p1 = 3 p2 = 37 p2 = 2 3 7 9 10 13 14 p1 = 3 p2 = 43 p1 = 3 p2 = 43 p2 = 3 5 9 10 13 15 p1 = 5 p2 = 47 p1 = 5 p2 = 47 p2 = 3 5 7 10 13 15 16 p1 = 5 p2 = 53 p1 = 5 p2 = 53 p2 = 2 3 5 7 9 13 15 16 17 18 p1 = 3 p2 = 61 p1 = 3 p2 = 61 p2 = 2 5 7 9 10 13 15 16 17 19 p1 = 3 p2 = 67 p1 = 3 p2 = 67 p2 = 2 3 7 9 10 15 16 17 20 21 p1 = 3 p2 = 73 p1 = 3 p2 = 73

2   Pass
nList = [18 20 22 100 102 114 1000 2000 36 3600]; for i = 1:length(nList) n = nList(i); [p1,p2] = goldbach(n) assert(isprime(p1) && isprime(p2) && (p1+p2==n)); end

p2 = 3 4 5 6 p1 = 5 p2 = 13 p1 = 5 p2 = 13 p2 = 2 4 6 7 p1 = 3 p2 = 17 p1 = 3 p2 = 17 p2 = 2 3 5 7 8 p1 = 3 p2 = 19 p1 = 3 p2 = 19 p2 = 2 5 7 10 13 15 16 17 20 23 24 25 p1 = 3 p2 = 97 p1 = 3 p2 = 97 p2 = 3 6 8 9 10 11 13 14 17 18 20 21 22 23 24 25 p1 = 5 p2 = 97 p1 = 5 p2 = 97 p2 = 3 4 5 6 7 11 13 14 15 16 18 19 20 21 23 25 26 27 28 29 p1 = 5 p2 = 109 p1 = 5 p2 = 109 p2 = Columns 1 through 29 2 7 9 10 15 16 17 20 24 30 33 40 41 43 49 52 55 60 66 69 71 72 76 79 83 86 92 94 97 Columns 30 through 56 98 102 104 109 113 116 118 119 124 128 132 135 137 140 142 144 150 154 156 158 160 161 162 164 165 166 168 p1 = 3 p2 = 997 p1 = 3 p2 = 997 p2 = Columns 1 through 29 2 4 6 19 31 34 46 47 48 53 59 63 67 68 74 75 82 84 88 100 101 105 106 110 114 122 127 133 136 Columns 30 through 58 138 145 151 153 155 159 163 167 169 174 179 183 187 188 193 198 202 204 210 217 221 222 224 226 231 232 243 247 249 Columns 59 through 74 257 258 261 263 264 269 274 275 278 279 284 287 295 300 301 302 p1 = 3 p2 = 1997 p1 = 3 p2 = 1997 p2 = 3 4 6 7 8 9 10 11 p1 = 5 p2 = 31 p1 = 5 p2 = 31 p2 = Columns 1 through 29 4 7 8 10 13 14 16 17 18 19 20 21 23 24 26 29 32 33 34 36 39 44 47 49 50 52 53 55 57 Columns 30 through 58 58 59 60 62 69 70 75 76 78 80 81 83 84 90 92 94 98 103 106 109 110 115 117 118 121 122 124 125 131 Columns 59 through 87 132 134 139 140 141 143 149 152 154 155 156 158 159 160 162 163 166 167 169 172 176 177 178 180 184 188 191 192 197 Columns 88 through 116 199 200 201 204 205 209 210 213 214 215 217 218 228 229 232 233 236 237 240 242 248 250 251 252 253 255 257 258 262 Columns 117 through 145 263 264 266 268 269 270 273 275 278 280 281 283 285 288 289 291 292 294 295 298 299 300 301 303 304 306 308 312 316 Columns 146 through 174 318 319 320 323 325 326 333 338 339 341 342 343 344 347 349 351 352 354 357 361 363 367 368 370 371 373 374 376 377 Columns 175 through 203 379 380 382 383 385 386 387 391 392 396 397 400 404 405 406 409 413 415 416 421 422 423 424 425 426 428 430 431 434 Columns 204 through 232 435 440 443 445 446 448 449 450 452 453 455 456 458 459 465 467 468 469 470 471 473 474 475 476 477 479 481 482 484 Columns 233 through 250 485 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 p1 = 7 p2 = 3593 p1 = 7 p2 = 3593