Problem Statement: Given N digits (limited to 1-9, and not duplicated) calculate the total sum of R permutation of N digits.
I've worked out the problem to the following solution:
sum of digits * how many digits -1 * multiplier
Solution sample if given 7 digits:
Digits = 1562734
Sum of digits = 28
R = 1; 28
R = 2; 28 * 6 * 2 = 336
R = 3; 28 * 6 * 15 = 2,520
R = 4; 28 * 6 * 80 = 13,440
R = 5; 28 * 6 * 300 = 50,400
R = 6; 28 * 6 * 720 = 120,960
R = 7; 28 * 6 * 840 = 141,120
Total grand sum = 328,804
More Info: If I am doing silly math here, I apologize. I am solving this in python and I can hardcode this multiplier values. I can just create a list depending on how many digits these multiplier values as I call them change depending if is 7, 8, or 9 digits and I already tested this with several digits combinations and the results are good. By the way for less than 7 digits I am doing iteration since is not taking too long as far as computation time goes.
Link to challenge for additional information: challenge page
Question: Is there any other way to calculate the sum, or can this multiplier be found somehow? I'm not sure which tags to add, if combinations is wrong please edit the post.