Cody

# Problem 44403. Goldbach's marginal conjecture - Write integer as sum of three primes

Solution 1342503

Submitted on 14 Nov 2017 by David Verrelli
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 = 6; y = goldbach3(n); y_correct = [2,2,2]; assert(isequal(y,y_correct))

y = 2 2 2

2   Pass
n = 7; y = goldbach3(n); y_correct = [2,2,3]; assert(isequal(y,y_correct))

y = 2 2 3

3   Pass
n = 8; y = goldbach3(n); y_correct = [2,3,3]; assert(isequal(y,y_correct))

y = 2 3 3

4   Pass
n = 9; y = goldbach3(n); y_correct1 = [2,2,5]; y_correct2 = [3,3,3]; assert(isequal(y,y_correct1)|isequal(y,y_correct2))

y = 2 2 5

5   Pass
n = 10; y = goldbach3(n); y_correct = [2,3,5]; assert(isequal(y,y_correct))

y = 2 3 5

6   Pass
n = 11; y = goldbach3(n); y_correct1 = [2,2,7]; y_correct2 = [3,3,5]; assert(isequal(y,y_correct1)|isequal(y,y_correct2))

y = 2 2 7

7   Pass
n = 12; y = goldbach3(n); y_correct1 = [2,3,7]; y_correct2 = [2,5,5]; assert(isequal(y,y_correct1)|isequal(y,y_correct2))

y = 2 3 7

8   Pass
n = 13; y = goldbach3(n); y_correct1 = [3,3,7]; y_correct2 = [3,5,5]; assert(isequal(y,y_correct1)|isequal(y,y_correct2))

y = 3 3 7

9   Pass
n = 14; y = goldbach3(n); y_correct = [2,5,7]; assert(isequal(y,y_correct))

y = 2 5 7

10   Pass
n = 15; y = goldbach3(n); y_correct1 = [2,2,11]; y_correct2 = [3,5,7]; y_correct3 = [5,5,5]; assert(isequal(y,y_correct1)|isequal(y,y_correct2)|isequal(y,y_correct3))

y = 2 2 11

11   Pass
n = 101; y = goldbach3(n); assert(isequal(y,sort(y))) assert(all(isprime(y))) assert(sum(y)==n)

y = 2 2 97

12   Pass
n = 102; y = goldbach3(n); assert(isequal(y,sort(y))) assert(all(isprime(y))) assert(sum(y)==n)

y = 2 3 97

13   Pass
for n = 250:300 y = goldbach3(n); assert(isequal(y,sort(y))); assert(all(isprime(y))); assert(sum(y)==n); end

y = 2 7 241 y = 3 7 241 y = 2 11 239 y = 3 11 239 y = 2 11 241 y = 2 2 251 y = 2 3 251 y = 3 3 251 y = 2 5 251 y = 3 5 251 y = 2 7 251 y = 2 2 257 y = 2 3 257 y = 3 3 257 y = 2 5 257 y = 3 5 257 y = 2 7 257 y = 2 2 263 y = 2 3 263 y = 3 3 263 y = 2 5 263 y = 3 5 263 y = 2 7 263 y = 2 2 269 y = 2 3 269 y = 2 2 271 y = 2 3 271 y = 3 3 271 y = 2 5 271 y = 3 5 271 y = 2 7 271 y = 2 2 277 y = 2 3 277 y = 3 3 277 y = 2 5 277 y = 2 2 281 y = 2 3 281 y = 2 2 283 y = 2 3 283 y = 3 3 283 y = 2 5 283 y = 3 5 283 y = 2 7 283 y = 3 7 283 y = 2 11 281 y = 3 11 281 y = 2 11 283 y = 2 2 293 y = 2 3 293 y = 3 3 293 y = 2 5 293

14   Pass
n = randi(2000)+5; % generate a random integer greater than 5 and smaller than 2006 y = goldbach3(n); assert(isequal(y,sort(y))) assert(all(isprime(y))) assert(sum(y)==n)

y = 3 3 103

15   Pass
valid = zeros(1,50); for k = 1:50 n = randi(1000)+5; % generate a random integer greater than 5 and smaller than 1006 yk = goldbach3(n); valid(k) = (isequal(yk,sort(yk)) & all(isprime(yk)) & sum(yk)==n); end assert(all(valid));

y = 2 23 617 y = 2 29 317 y = 2 3 953 y = 3 7 491 y = 2 5 709 y = 2 17 683 y = 2 7 811 y = 3 7 113 y = 3 5 631 y = 2 5 647 y = 2 7 263 y = 2 19 349 y = 2 3 13 y = 3 7 719 y = 2 3 79 y = 2 3 241 y = 3 11 661 y = 2 5 491 y = 3 7 283 y = 3 5 53 y = 3 3 173 y = 2 7 151 y = 3 13 109 y = 2 3 157 y = 2 3 977 y = 2 3 929 y = 2 7 829 y = 2 3 463 y = 2 3 653 y = 3 3 557 y = 2 2 271 y = 2 7 991 y = 2 7 773 y = 2 5 89 y = 3 11 239 y = 3 7 631 y = 2 2 809 y = 3 3 109 y = 2 5 929 y = 2 2 977 y = 2 2 83 y = 3 3 631 y = 2 2 877 y = 2 5 797 y = 3 5 677 y = 3 7 863 y = 2 5 991 y = 2 3 787 y = 2 5 523 y = 2 3 491