Thursday 6 April 2017

Algorithm to Check Given Two Numbers are Twins Prime or Not


Step 1 : Start
Step 2 : Read Num1, Num2
Step 3 :  i = 2,j = 2,flag1 = 0,flag2 = 0  
Step 4 : if  i <=  Num1 / 2 then go to Step 5 
             else go to Step 8
Step 5 : if  Num1 % i = 0 then go to Step 6
             else go to Step 7
Step 6 : flag1 = 1 ,then go to Step 14
Step 7 : i = i + 1 , then  go to Step 4
Step 8 : if  j <=  Num2 / 2 then go to Step 9
             else go to Step  13
Step 9 : if  Num2 % i = 0 then go to Step 10
             else go to Step 11 
Step 10 : flag2 = 1 ,then go to Step 14
Step 11 : i = i + 1 , then  go to Step 8
Step 12 : if  flag1 = 0 and flag2 = 0 then go to Step 13
               else go to Step 14 
Step 13 : if Num1 - Num2 = 2  or Num2 - Num1 = 2 go to Step 15
                else go to Step 14
Step 14 : print "Numbers are not Twins Prime" ,go to Step 16
Step 15 : print "Numbers are Twins Prime" ,go to Step 16
Step 16 : 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...