MATLAB Assignments Samples- Prime Numbers

Problem Statement: To check that given integer is prime number or not. n>1 n= input('Enter an integer >1: '); divisor= 2; while ( rem(n,divisor)~=0 ) divisor= divisor + 1; end if (divisor==n) fprintf('%d is prime\n', n) else fprintf('%d is composite\n', … Read More...