Cody

Solution 283401

Submitted on 16 Jul 2013 by David Melton
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

p = 2 3 5 7 11 13 17 19 23 ans = 0 0 1 0 1 0 1 0 1 ans = 5 23 11 17 17 11 23 5 p = 5 23 11 17 17 11 23 5 p1 = 5 p2 = 23 p1 = 5 p2 = 23 p = 2 3 5 7 11 13 17 19 23 29 31 ans = 0 1 1 0 1 0 1 0 1 1 1 ans = 3 31 5 29 11 23 17 17 23 11 29 5 31 3 p = 3 31 5 29 11 23 17 17 23 11 29 5 31 3 p1 = 3 p2 = 31 p1 = 3 p2 = 31 p = 2 3 5 7 11 13 17 19 23 29 31 37 ans = 0 1 0 0 1 0 1 0 1 1 0 1 ans = 3 37 11 29 17 23 23 17 29 11 37 3 p = 3 37 11 29 17 23 23 17 29 11 37 3 p1 = 3 p2 = 37 p1 = 3 p2 = 37 p = 2 3 5 7 11 13 17 19 23 29 31 37 41 43 ans = 0 1 1 0 0 0 1 0 1 1 0 0 1 1 ans = 3 43 5 41 17 29 23 23 29 17 41 5 43 3 p = 3 43 5 41 17 29 23 23 29 17 41 5 43 3 p1 = 3 p2 = 43 p1 = 3 p2 = 43 p = 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 ans = 0 0 1 0 1 0 0 0 1 1 0 0 1 0 1 ans = 5 47 11 41 23 29 29 23 41 11 47 5 p = 5 47 11 41 23 29 29 23 41 11 47 5 p1 = 5 p2 = 47 p1 = 5 p2 = 47 p = 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 ans = 0 0 1 0 1 0 1 0 0 1 0 0 1 0 1 1 ans = 5 53 11 47 17 41 29 29 41 17 47 11 53 5 p = 5 53 11 47 17 41 29 29 41 17 47 11 53 5 p1 = 5 p2 = 53 p1 = 5 p2 = 53 p = Columns 1 through 16 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 Columns 17 through 18 59 61 ans = Columns 1 through 16 0 1 1 0 1 0 1 0 1 0 0 0 1 0 1 1 Columns 17 through 18 1 1 ans = 3 61 5 59 11 53 17 47 23 41 41 23 47 17 53 11 59 5 61 3 p = 3 61 5 59 11 53 17 47 23 41 41 23 47 17 53 11 59 5 61 3 p1 = 3 p2 = 61 p1 = 3 p2 = 61 p = Columns 1 through 16 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 Columns 17 through 19 59 61 67 ans = Columns 1 through 16 0 1 0 0 1 0 1 0 1 1 0 0 1 0 1 1 Columns 17 through 19 1 0 1 ans = 3 67 11 59 17 53 23 47 29 41 41 29 47 23 53 17 59 11 67 3 p = 3 67 11 59 17 53 23 47 29 41 41 29 47 23 53 17 59 11 67 3 p1 = 3 p2 = 67 p1 = 3 p2 = 67 p = Columns 1 through 16 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 Columns 17 through 21 59 61 67 71 73 ans = Columns 1 through 16 0 1 1 0 0 0 1 0 1 1 0 0 0 0 1 1 Columns 17 through 21 1 0 0 1 1 ans = 3 73 5 71 17 59 23 53 29 47 47 29 53 23 59 17 71 5 73 3 p = 3 73 5 71 17 59 23 53 29 47 47 29 53 23 59 17 71 5 73 3 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

p = 2 3 5 7 11 13 17 ans = 0 0 1 1 1 1 0 ans = 5 13 7 11 11 7 13 5 p = 5 13 7 11 11 7 13 5 p1 = 5 p2 = 13 p1 = 5 p2 = 13 p = 2 3 5 7 11 13 17 19 ans = 0 1 0 1 0 1 1 0 ans = 3 17 7 13 13 7 17 3 p = 3 17 7 13 13 7 17 3 p1 = 3 p2 = 17 p1 = 3 p2 = 17 p = 2 3 5 7 11 13 17 19 ans = 0 1 1 0 1 0 1 1 ans = 3 19 5 17 11 11 17 5 19 3 p = 3 19 5 17 11 11 17 5 19 3 p1 = 3 p2 = 19 p1 = 3 p2 = 19 p = Columns 1 through 16 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 Columns 17 through 25 59 61 67 71 73 79 83 89 97 ans = Columns 1 through 16 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 1 Columns 17 through 25 1 0 0 1 0 0 1 1 1 ans = 3 97 11 89 17 83 29 71 41 59 47 53 53 47 59 41 71 29 83 17 89 11 97 3 p = 3 97 11 89 17 83 29 71 41 59 47 53 53 47 59 41 71 29 83 17 89 11 97 3 p1 = 3 p2 = 97 p1 = 3 p2 = 97 p = Columns 1 through 16 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 Columns 17 through 26 59 61 67 71 73 79 83 89 97 101 ans = Columns 1 through 16 0 0 1 0 0 1 0 1 1 1 1 0 1 1 0 0 Columns 17 through 26 1 1 0 1 1 1 1 1 1 0 ans = 5 97 13 89 19 83 23 79 29 73 31 71 41 61 43 59 59 43 61 41 71 31 73 29 79 23 83 19 89 13 97 5 p = 5 97 13 89 19 83 23 79 29 73 31 71 41 61 43 59 59 43 61 41 71 31 73 29 79 23 83 19 89 13 97 5 p1 = 5 p2 = 97 p1 = 5 p2 = 97 p = Columns 1 through 16 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 Columns 17 through 30 59 61 67 71 73 79 83 89 97 101 103 107 109 113 ans = Columns 1 through 16 0 0 1 1 1 1 1 0 0 0 1 0 1 1 1 1 Columns 17 through 30 0 1 1 1 1 0 1 0 1 1 1 1 1 0 ans = 5 109 7 107 11 103 13 101 17 97 31 83 41 73 43 71 47 67 53 61 61 53 67 47 71 43 73 41 83 31 97 17 101 13 103 11 107 7 109 5 p = 5 109 7 107 11 103 13 101 17 97 31 83 41 73 43 71 47 67 53 61 61 53 67 47 71 43 73 41 83 31 97 17 101 13 103 11 107 7 109 5 p1 = 5 p2 = 109 p1 = 5 p2 = 109 p = Columns 1 through 16 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 Columns 17 through 32 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 Columns 33 through 48 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 Columns 49 through 64 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 Columns 65 through 80 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 Columns 81 through 96 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 Columns 97 through 112 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 Columns 113 through 128 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 Columns 129 through 144 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 Columns 145 through 160 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 Columns 161 through 168 947 953 967 971 977 983 991 997 ans = Columns 1 through 16 0 1 0 0 0 0 1 0 1 1 0 0 0 0 1 1 Columns 17 through 32 1 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 Columns 33 through 48 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 Columns 49 through 64 1 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 Columns 65 through 80 0 1 0 0 1 0 1 1 0 0 0 1 0 0 1 0 Columns 81 through 96 0 0 1 0 0 1 0 0 0 0 0 1 0 1 0 0 Columns 97 through 112 1 1 0 0 0 1 0 1 0 0 0 0 1 0 0 0 Columns 113 through 128 1 0 0 1 0 1 1 0 0 0 0 1 0 0 0 1 Columns 129 through 144 0 0 0 1 0 0 1 0 1 0 0 1 0 1 0 1 Columns 145 through 160 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 1 Columns 161 through 168 1 1 0 1 1 1 0 1 ans = 3 997 17 983 23 977 29 971 47 953 53 947 59 941 71 929 89 911 113 887 137 863 173 827 179 821 191 809 227 773 239 761 257 743 281 719 317 683 347 653 353 647 359 641 383 617 401 599 431 569 443 557 479 521 491 509 509 491 521 479 557 443 569 431 599 401 617 383 641 359 647 353 653 347 683 317 719 281 743 257 761 239 773 227 809 191 821 179 827 173 863 137 887 113 911 89 929 71 941 59 947 53 953 47 971 29 977 23 983 17 997 3 p = 3 997 17 983 23 977 29 971 47 953 53 947 59 941 71 929 89 911 113 887 137 863 173 827 179 821 191 809 227 773 239 761 257 743 281 719 317 683 347 653 353 647 359 641 383 617 401 599 431 569 443 557 479 521 491 509 509 491 521 479 557 443 569 431 599 401 617 383 641 359 647 353 653 347 683 317 719 281 743 257 761 239 773 227 809 191 821 179 827 173 863 137 887 113 911 89 929 71 941 59 947 53 953 47 971 29 977 23 983 17 997 3 p1 = 3 p2 = 997 p1 = 3 p2 = 997 p = Columns 1 through 8 2 3 5 7 11 13 17 19 Columns 9 through 16 23 29 31 37 41 43 47 53 Columns 17 through 24 59 61 67 71 73 79 83 89 Columns 25 through 32 97 101 103 107 109 113 127 131 Columns 33 through 40 137 139 149 151 157 163 167 173 Columns 41 through 48 179 181 191 193 197 199 211 223 Columns 49 through 56 227 229 233 239 241 251 257 263 Columns 57 through 64 269 271 277 281 283 293 307 311 Columns 65 through 72 313 317 331 337 347 349 353 359 Columns 73 through 80 367 373 379 383 389 397 401 409 Columns 81 through 88 419 421 431 433 439 443 449 457 Columns 89 through 96 461 463 467 479 487 491 499 503 Columns 97 through 104 509 521 523 541 547 557 563 569 Columns 105 through 112 571 577 587 593 599 601 607 613 Columns 113 through 120 617 619 631 641 643 647 653 659 Columns 121 through 128 661 673 677 683 691 701 709 719 Columns 129 through 136 727 733 739 743 751 757 761 769 Columns 137 through 144 773 787 797 809 811 821 823 827 Columns 145 through 152 829 839 853 857 859 863 877 881 Columns 153 through 160 883...

Suggested Problems

More from this Author95