Cody

Solution 241082

Submitted on 7 May 2013 by Vishwasrao
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

a = Columns 1 through 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 17 through 25 18 19 20 21 22 23 24 25 26 b = Columns 1 through 16 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 Columns 17 through 25 10 9 8 7 6 5 4 3 2 p2 = 23 p1 = 5 p2 = 23 a = Columns 1 through 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 17 through 31 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 b = Columns 1 through 16 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 Columns 17 through 31 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 p2 = 31 p1 = 3 p2 = 31 a = Columns 1 through 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 17 through 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Columns 33 through 37 34 35 36 37 38 b = Columns 1 through 16 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 Columns 17 through 32 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 Columns 33 through 37 6 5 4 3 2 p2 = 37 p1 = 3 p2 = 37 a = Columns 1 through 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 17 through 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Columns 33 through 43 34 35 36 37 38 39 40 41 42 43 44 b = Columns 1 through 16 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 Columns 17 through 32 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 Columns 33 through 43 12 11 10 9 8 7 6 5 4 3 2 p2 = 43 p1 = 3 p2 = 43 a = Columns 1 through 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 17 through 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Columns 33 through 48 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 Column 49 50 b = Columns 1 through 16 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 Columns 17 through 32 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 Columns 33 through 48 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 Column 49 2 p2 = 47 p1 = 5 p2 = 47 a = Columns 1 through 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 17 through 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Columns 33 through 48 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 Columns 49 through 55 50 51 52 53 54 55 56 b = Columns 1 through 16 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 Columns 17 through 32 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 Columns 33 through 48 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 Columns 49 through 55 8 7 6 5 4 3 2 p2 = 53 p1 = 5 p2 = 53 a = Columns 1 through 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 17 through 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Columns 33 through 48 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 Columns 49 through 61 50 51 52 53 54 55 56 57 58 59 60 61 62 b = Columns 1 through 16 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 Columns 17 through 32 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 Columns 33 through 48 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 Columns 49 through 61 14 13 12 11 10 9 8 7 6 5 4 3 2 p2 = 61 p1 = 3 p2 = 61 a = Columns 1 through 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 17 through 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Columns 33 through 48 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 Columns 49 through 64 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 Columns 65 through 67 66 67 68 b = Columns 1 through 16 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 Columns 17 through 32 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 Columns 33 through 48 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 Columns 49 through 64 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 Columns 65 through 67 4 3 2 p2 = 67 p1 = 3 p2 = 67 a = Columns 1 through 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 17 through 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Columns 33 through 48 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 Columns 49 through 64 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 Columns 65 through 73 66 67 68 69 70 71 72 73 74 b = Columns 1 through 16 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 Columns 17 through 32 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 Columns 33 through 48 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 Columns 49 through 64 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 Columns 65 through 73 10 9 8 7 6 5 4 3 2 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

a = 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 b = 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 p2 = 13 p1 = 5 p2 = 13 a = Columns 1 through 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Column 17 18 b = Columns 1 through 16 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 Column 17 2 p2 = 17 p1 = 3 p2 = 17 a = Columns 1 through 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 17 through 19 18 19 20 b = Columns 1 through 16 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 Columns 17 through 19 4 3 2 p2 = 19 p1 = 3 p2 = 19 a = Columns 1 through 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 17 through 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Columns 33 through 48 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 Columns 49 through 64 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 Columns 65 through 80 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 Columns 81 through 96 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 Column 97 98 b = Columns 1 through 16 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 Columns 17 through 32 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 Columns 33 through 48 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 Columns 49 through 64 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 Columns 65 through 80 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 Columns 81 through 96 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 Column 97 2 p2 = 97 p1 = 3 p2 = 97 a = Columns 1 through 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 17 through 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Columns 33 through 48 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 Columns 49 through 64 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 Columns 65 through 80 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 Columns 81 through 96 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 Columns 97 through 99 98 99 100 b = Columns 1 through 16 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 Columns 17 through 32 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 Columns 33 through 48 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 Columns 49 through 64 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 Columns 65 through 80 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 Columns 81 through 96 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 Columns 97 through 99 4 3 2 p2 = 97 p1 = 5 p2 = 97 a = Columns 1 through 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 17 through 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Columns 33 through 48 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 Columns 49 through 64 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 Columns 65 through 80 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 Columns 81 through 96 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 Columns 97 through 111 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 b = Columns 1 through 16 112 111 110 109 108 107 106 105 104 103 102 101 100 99 98 97 Columns 17 through 32 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 Columns 33 through 48 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 Columns 49 through 64 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 Columns 65 through 80 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 Columns 81 through 96 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 Columns 97 through 111 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 p2 = 109 p1 = 5 p2 = 109 a = Columns 1 through 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 17 through 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Columns 33 through 48 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 Columns 49 through 64 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 Columns 65 through 80 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 Columns 81 through 96 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 Columns 97 through 112 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 Columns 113 through 128 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 Columns 129 through 144 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 Columns 145 through 160 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 Columns 161 through 176 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 Columns 177 through 192 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 Columns 193 through 208 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 Columns 209 through 224 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 Columns 225 through 240 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 Columns 241 through 256 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 Columns 257 through 272 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 Columns 273 through 288 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 Columns 289 through 304 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 Columns 305 through 320 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 Columns 321 through 336 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 Columns 337 through 352 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 Columns 353 through 368 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 Columns 369 through 384 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 Columns 385 through 400 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 Columns 401 through 416 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 Columns 417 through 432 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 Columns 433 through 448 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 Columns 449 through 464 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 Columns 465 through 480 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 Columns 481 through 496 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 Columns 497 through 512 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 Columns 513 through 528 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 Columns 529 through 544 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 Columns 545 through 560 546 547 548 549 550 551 552 ...