Convert A into B by incrementing or decrementing 1 , 2 , or 5 any number of times | C # program for the above approach ; Function to find minimum number of moves required to convert A into B ; Stores the minimum number of moves required ; Stores the absolute difference ; FInd the number of moves ; Return cnt ; Driver Code ; Input ; Function call
using System ; using System . Collections . Generic ; class GFG { static int minimumSteps ( int a , int b ) { int cnt = 0 ; a = Math . Abs ( a - b ) ; cnt = ( a / 5 ) + ( a % 5 ) / 2 + ( a % 5 ) % 2 ; return cnt ; } public static void Main ( ) { int A = 3 , B = 9 ; Console . Write ( minimumSteps ( A , B ) ) ; } }