Question: summation with for loop

Hello, I want to solve out this, Please replace this text with the link to your file. The link can be found in the File Manager

> f1:=factorial(n+1)*((r+1-i)^n)*((-1)^i)/(factorial(i)*factorial(n+1-i));

> f2:=factorial((2^k)+n-r)/((2^(n*k))*factorial(n)*factorial((2^k)-r));

> f3:=sum (f1,i=0..r);

> f4:=abs((factorial((2^k)+n-r)/((2^(n*k))*factorial(n)*factorial((2^k)-r))-1/factorial(n)));

> f5:=f3*f4;

> dr:=(1/2)*sum(f5,r=1..n);

This dr is my mathematical model. I am trying to use for loops for summations and k starts from 1 to 10. Since n is the number of cards, n is variable. I should input n, similar to scanf in c++. I need to find dr and I need to draw a graph k versas dr.

This post was generated using the MaplePrimes File Manager

View 3966_shuffle model.mw on MapleNet or Download 3966_shuffle model.mw
View file details

> restart;

> dr:=proc(n::integer)
local i,r,k;
global f1,f2,f3,f4,f5,f6,dr;
for k from 1 to 10 do
for r from 1 to n do
f1:=factorial(n+1)*((r+1-i)^n)*((-1)^i)/(factorial(i)*factorial(n+1-i)):
f4:=summation(f1,i=0..r);
f2:=factorial((2^k)+n-r)/((2^(n*k))*factorial(n)*factorial((2^k)-r)):
f3:=1/(factorial(n)):
f5:=f4*f2*f3:
f6:=summation(f5,r=1..n);
od;
od;
dr:=f6/2;
end:

>

This post was generated using the MaplePrimes File Manager

View 3966_shuffle.mw on MapleNet or Download 3966_shuffle.mw
View file details

Then, this is my program that I wrote. There is nothing came out. I know I did something wrong, but I do not know what. Thank you. Regards, Eun-saem Lee
Please Wait...