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

1) Write a matlab scripts for the following to accept two numbers from the user

ID: 3914644 • Letter: 1

Question

1) Write a matlab scripts for the following to accept two numbers from the user and display Prime number between these two number

2) Write a matlab scripts for the following to accept two numbers from the user and display Perfect number between these two number

2. Write MATLAB scripts for the following:Etarer a. To accept two numbers from the user; Display all prime numbers between these two numbers. 6 Marks) b. To accept two numbers from the user and display perfect numbers between these two numbers. (6 Marks) c. To accept two numbers from the user and display Armstrong number between these numbers. (6 Marks)

Explanation / Answer

Write a matlab scripts for the following to accept two numbers from the user and display Prime number between these two number

clc

for num = int1:int2

for fact = 2:num

if fact == num

fprintf("%d is a prime number. ",num)

elseif rem(num,fact) == 0

break

else

#fprintf("Check next. ")

end

end

end

3) Write a matlab scripts for the following to accept two numbers from the user and display Armstrong number between these two number

for (number = int1:int2)

numstr = num2str(number);

sum = 0;

for (digit = 1:length(numstr))

digitcube = str2num(numstr(digit)) ^ 3;

sum = sum + digitcube;

end

if (sum == number)

clc

  int1 = input("Please input the first number:  ");  int2 = input("Please input the second number:  ");

for num = int1:int2

for fact = 2:num

if fact == num

fprintf("%d is a prime number. ",num)

elseif rem(num,fact) == 0

break

else

#fprintf("Check next. ")

end

end

end