Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

#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





Live Support: t.me/matlabirawen


 

 


No comments

Popular Posts

Followers