Thursday 6 April 2017

Algorithm to Check Whether Two Numbers are Amicable or Not


Step 1 : Start
Step 2 : Read Num1, Num2
Step 3 :  i = 1
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 : Sum1 = Sum1 + i
Step 7 : i = i + 1 , then  go to Step 4
Step 8 : i = 1
Step 9 : if  i <=  Num2 / 2 then go to Step 10 

             else go to Step 13
Step 10 : if  Num2 % i = 0 then go to Step 11
             else go to Step 12
Step 11 : Sum2 = Sum2 + i

Step 12 : i = i + 1 , then  go to Step 9
Step 13 : if Sum1 = Num2 and Sum2 = Num1 then go to Step 14
               else go to Step 15 
Step 14 : print "Numbers are Amicable" ,go to Step 16
Step 15 : print "Numbers are not amicable" ,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...