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', n)
end

Problem Statement: Print the list of all prime number between a given range

a= input('Enter a positive integer: ');
b= input('Enter an integer greater than the previous value: ');

for n= a:b

    % Determine whether n is prime
    divisor= 2;
    while ( mod(n,divisor)~=0 )
        divisor= divisor + 1;
    end
    if (divisor==n)
        fprintf('%d is prime\n', n)
    end

end

Other problem statements:

  1. Find the sum of prime numbers in given range
  2. To find out prime factorization of given numbers
  3. Cryptography related problems

If you need MATLAB releted help,visit  https://www.essaycorp.com/matlab-assignment-help.html to get experts’ assistance.

 

Author:
Category :
Publish Date :
    Social Sharing