Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Special Topics Fall 2017 Take Home Project #2 (Due on Tuesday, December 5th, BEF

ID: 2265689 • Letter: S

Question

Special Topics Fall 2017 Take Home Project #2 (Due on Tuesday, December 5th, BEFORE the class session) Write a MATLAB code that will perform the following tasks: 1. Asks the user to enter two different integers. 2. Find all prime numbers within the two numbers and printing them on the command window. 3. Requests if the user wishes to continue by entering 1 for continue and 0 for termination of the program. Notice that you must use function as part of your code to complete this task, along with branching and loops. Provide all the required for a paper copy Notice that each student should present their own work and methodology. Any similarities between codes will result in a ZERO grade for all students involved. Late submissions policy: a deduction of the overal mark of any submission later than date and time provided will be a 20% for every 24 hours late, accumulatively, Good Luck!

Explanation / Answer

Matlab Script:

function primedisplay()
while 1==1
n1 = input('Please enter different numbers 1 by 1');
n2 = input('Please enter another number');
for i=n1:n2%taking the range from n1 to n2
count=0;
for j=2:i-1
if mod(i,j)==0 %finding if it divisible by other number
count=count+1;%if divisible we will increment count
break
end
end
if count==0 && i~=1%if count is not equal to zero then that is not prime number
disp(i);
end
end
choice1 = input('Would you like to continue');
if choice1==0
break;%we wil break the loop if choice is 0
end   
end
end

Command window output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote