Write an algorithm to produce the sum and product of the two

Write an algorithm to produce the sum and product of the two consecutive numbers produced by the following expressions (DISCRETE MATH)

Write an algorithm to produce the sum and product of the two consecutive numbers produced by the following expressions. Assume So S11 >n-1+ n-2 n-1 n-2 Algorithm should have the outputs S and P up to 50 terms

Solution

The generic reasoning can be inferred from a small example.

Assume we have three numbers we want to sum to 4. The number of ways to do this is the same as setting the first digit to k=4,3,2,1,0k=4,3,2,1,0 in turn and then using the remaining digits to sum up to k1k1.

number of ways to write 4 with three digits =

{4 + {number of ways to write 0 with two digits}} +

{3 + {number of ways to write 1 with two digits}} +

{2 + {number of ways to write 2 with two digits}} +

{1 + {number of ways to write 3 with two digits}} +

{0 + {number of ways to write 4 with two digits}}

(You might want to convince yourself that this is the case and there is no need to assume the set digit in different positions)

Which is the same as writing (in our notation)

F3(4)=F2(0)+F2(1)+F2(2)+F2(3)+F2(4)F3(4)=F2(0)+F2(1)+F2(2)+F2(3)+F2(4)

For the general case we have

Fk(n)=nl=0Fk1(l)Fk(n)=l=0nFk1(l)

it is also easily seen that F1(n)=1F1(n)=1 and Fk(0)=1Fk(0)=1. This now allows us to expand the first few relations as

F1(n)=1F1(n)=1

F2(n)=l=0nF1(l)=(n+1)1!F2(n)=l=0nF1(l)=(n+1)1!

F3(n)=l=0nF2(l)=l=0nn+1=(n+1)2+(n+1)2!F3(n)=l=0nF2(l)=l=0nn+1=(n+1)2+(n+1)2!

F4(n)=l=0nF3(l)=(n+1)3+3(n+1)2+2(n+1)3!F4(n)=l=0nF3(l)=(n+1)3+3(n+1)2+2(n+1)3!

F5(n)=l=0nF4(l)=(n+1)4+6(n+1)3+11(n+1)2+6(n+1)4!F5(n)=l=0nF4(l)=(n+1)4+6(n+1)3+11(n+1)2+6(n+1)4!

... and so on

Unfortunately there isn\'t any \"nice\" generic expression for the coefficients in the numerator. Its a good exercise to find it but be warned; it gets quite messy apart from the two highest and the lowest coefficients in the numerator polynomial which you probably can spot by inspection.

Write an algorithm to produce the sum and product of the two consecutive numbers produced by the following expressions (DISCRETE MATH) Write an algorithm to pro

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site