MATLAB: Stop value in loop for repeating

loops

clc;
clear;
close all;
rng('shuffle');
myint = randi([4,100]);
while mod(myint,2) ~= 0
myint = randi([4,100]);
end
fprintf('%d is the sum of these prime numbers\n',myint);
myprime = primes(myint);
mylength = ceil(length(myprime)/2);
for i=1:length(myprime)
for k=1:length(myprime)
if(myprime(i)+myprime(k)== myint)
num1 = myprime(i);
num2 = myprime(k);
fprintf('%d = %d + %d \n',myint,num1,num2)
end
end
end
i am trying to create the goldbach conjecture but I do not want the prime numbers that have already been listed to repeat. eg 7+5 and 5+7.

Best Answer

Not sure if you need the numbers to be different or not. Either this:
for k=i:length(myprime)
or this
for k=i+1:length(myprime)