自己修改n,这里试验的97
n = 97;
flag = 0;
for j = 3:2:n
for k = j:2:n
l = n - j - k;
retj = check_prime(j);
retk = check_prime(k);
retl = check_prime(l);
rett = retj * retk * retl;
if(rett == 1)
fprintf(1,'%d = %d + %d + %d\n', n, j, k, l);
flag = 1;
break;
end
end
if flag
break;
end
end
另外一个函数检查是否素数
function ret = check_prime(a)
ret = 1;
for i = 2:1:a-1
if(mod(a,i) == 0)
ret = 0;
break;
end
end
end