Sum of all Permutations
Page 1 of 1 • Share •
Sum of all Permutations
you are given a number n
you are to give the sum of all possible unique permutations
Example
0)
157
Returns: 2886
We have: 157 + 175 + 517 + 571 + 715 + 751 = 2886
1)
313
Returns: 777
We have: 133 + 313 + 331 = 777
2)
1234
Returns: 66660
3)
5
Returns: 5
4)
54321
Returns: 3999960
5)
99999
Returns: 99999
problem source SRM 252 topcoder
you are to give the sum of all possible unique permutations
Example
0)
157
Returns: 2886
We have: 157 + 175 + 517 + 571 + 715 + 751 = 2886
1)
313
Returns: 777
We have: 133 + 313 + 331 = 777
2)
1234
Returns: 66660
3)
5
Returns: 5
4)
54321
Returns: 3999960
5)
99999
Returns: 99999
problem source SRM 252 topcoder
prani- Posts: 15
Join date: 2008-08-12
Permissions of this forum:
You cannot reply to topics in this forum





