Count of distinct permutations of every possible length of given string | Function to find the factorial of a number ; Loop to find the factorial of the given number ; Function to find the number of permutations possible for a given string ; Function to find the total number of combinations possible ; Driver Code
function fact ( a ) { var i , f = 1 ; for ( i = 2 ; i <= a ; i ++ ) f = f * i ; return f ; } function permute ( n , r ) { var ans = 0 ; ans = ( fact ( n ) / fact ( n - r ) ) ; return ans ; } function findPermutations ( n ) { var sum = 0 , P ; for ( var r = 1 ; r <= n ; r ++ ) { P = permute ( n , r ) ; sum = sum + P ; } return sum ; } var str = " " ; var result , n ; n = str . length ; document . write ( findPermutations ( n ) ) ;