Tuesday 4 April 2017

Algorithm to Check a Number is Prime or Not


Step 1 : Start
Step 2 : Read Number
Step 3 :  i = 2 , Flag = 0
Step 4 : if  i <=  Number / 2 then go to Step 5  
             else go to Step 8
Step 5 : if  Number % i = 0 then go to Step 6
             else go to Step 7
Step 6 : Flag = 1 go to Step 10
Step 7 : i = i + 1 , then  go to Step 4
Step 8 : if  Flag = 1 then go to Step 10
             else go to Step 9
Step 9 : print "Number is Prime" ,go to Step 11
Step 10 : print "Number is not Prime" ,go to Step 11
Step 11 : Stop 

No comments:

Post a Comment

How to Invert an SVG image using CSS ?

You can invert your svg easily by using following css code svg { -webkit-filter: invert(100%); /* safari 6.0 - 9.0 */ filter...