jasser

95 Reputation

4 Badges

1 years, 363 days

MaplePrimes Activity


These are questions asked by jasser

Hello

I would like to write a process f(p,n) that returns the number of partions of a positive integer n into p parts. possible parts are only 0,1,4,6,8,9. these parts cn be used several times. the order is not important.

example

f(3,8)=3 because (0,0,8), (0,4,4), (1,1,6).

thanks for your help!

Hello
I would like to write a Maple program that gives me all possible sums >=  a given maximum maxsum and with and odd number q >= 3 of distinct summands from a given list. q can be 3, 5, 7, .. t, where t is odd and depends on L and max.

Example:
maxsum:=97, L := [9,15,21,25,27,33,35,39,45,49,51,55,57,63,65,69,75,77,81,85,87].

Here t= 3 and only q=3 is possible. In the final version of the program the list L and the maxsum will be much larger, so that the sums for every odd q =3, 5, 7, ..., t.

I tried to write a code for this basic case:

q := 3:
p := 91:
L := [9,15,21,25,27,33,35,39,45,49,51,55,57,63,65,69,75,77,81,85,87]:
M := []:

NestedLoops := proc(startIndex, remainingDepth, currentSum)
    local i;
    if remainingDepth = 0 then
        if currentSum <= p then
            M := [op(M), currentSum]:
        end if;
        return:
    end if;

    for i from startIndex to nops(L) - remainingDepth + 1 do
        NestedLoops(i + 1, remainingDepth - 1, currentSum + L[i]):
    od;
end proc:

NestedLoops(1, q, 0);
M;

The result ist "[]". What is wrong? How would be a correct and efficient version?

Thanks for helping me.

Hello

I am looking for an efficient code that calculates all partitions of a positive integer n into parts >1. Example:

for n=8 the program should return

[2,6],[3,5],[4,4],[2,2,4],[2,3,3],[[2,2,2,2].

The program should be able to calculate these partitions for n=1..10000 in reasonable time

Who can help me?

Thanks.

Hello

I programmed a sequence a(n). Up to a(42) Maple had no problem to calculate the term, but when calculating a(43), after a while appears the message

`System error, `, "bad id"

What does that mean and what can I do?
Thank you.

Hello

I would like to replace the expression

"floor(root(n,3))"

by another, more efficient one. Maybe something with iroot?

n is a positive integer.

Thanks for an answer.

1 2 3 Page 1 of 3