I dont understand what the problem with solution is ?
Your for loop bounds exceed the number of prime factors of n. Also, it looks like you are solving for the stated case n=286 and the test cases are using additional inputs.
Test | Status | Code Input and Output |
---|---|---|
1 | Fail |
%%
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
Error: Attempted to access prim(10); index out of bounds because numel(prim)=9.
|
2 | Fail |
%%
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
Error: Attempted to access prim(8); index out of bounds because numel(prim)=7.
|
1638 Solvers
Is my wife right? Now with even more wrong husband
1145 Solvers
281 Solvers
600 Solvers
502 Solvers