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

Search This Blog

Check prime number or not in constant time(without using any loop) | MATLAB


Code:

clc
clear all
close all
x=input('Enter the number:');
if(x==2 || x==3)
    disp('Prime number');
elseif(rem((x-1),6)==0 || rem((x+1),6)==0)
    disp('Prime number');
else
    disp('Not a prime number');
end


No comments

Popular Posts

Followers