Number of moves required to guess a permutation . | Function that returns the required moves ; Final move ; Driver Code
< ? php function countMoves ( $ n ) { $ ct = 0 ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) $ ct += $ i * ( $ n - $ i ) ; $ ct += $ n ; return $ ct ; } $ n = 3 ; echo countMoves ( $ n ) ; ? >