#Day81#100DaysChallenge- Matlab Loops|Prime Number in the given range
#Day81-Prime Number in the given range
Task:
Write a code to find prime number in given range
6 is Not a Prime Number
7 is Prime Number
8 is Not a Prime Number
9 is Not a Prime Number
Note: This code can be done using the in-built command. But for the challenge, I am trying to avoid those.
Matlab code
function primenumberinthegivenrange(l,u)
for num=l:1:u
fprintf('%d
is \t',num');
primeornot2(num);
fprintf('\n');
end
end
Sample Input and Output
primenumberinthegivenrange(6,9)
6 is Not a Prime Number
7 is Prime Number
8 is Not a Prime Number
9 is Not a Prime Number
Click here for Video Description
Free Codes: youtube.com/castorclasses
No comments