num1 = input('Enter Number 1: '); %prompt user for first number
num2 = input('Enter Number 2: '); %prompt user for second number
for x = num1:num2 %x is numbers in between num1 and num2
y = primes(x); %y is to find the primes between the 2 number
end fprintf('The primes between %d and %d are: \n',num1, num2); %tells the user the output
disp(y); %display the primes
this is my code and when the user input 15 and 30 for the first and second number, instead of getting prime numbers just from 15 to 30, the result is prime numbers from 1 to 30, how should i modify the code to get prime numbers just between num1 and num2? thanks!
Best Answer