Number of moves required to guess a permutation . | C # implementation of the approach ; Function that returns the required moves ; Final move ; Driver Program to test above function
using System ; class GFG { static int countMoves ( int n ) { int ct = 0 ; for ( int i = 1 ; i <= n ; i ++ ) ct += i * ( n - i ) ; ct += n ; return ct ; } static void Main ( ) { int n = 3 ; Console . WriteLine ( countMoves ( n ) ) ; } }