# Question:How to program a dynamical loop?

## Question:How to program a dynamical loop?

Maple 2023

Hello

I have programs below for the cases n=3 and n=4. If n is increasing by 1, then there is one loop more. As you can see, that additional loop has always the structure:

x[i+1] from ceil(((n-2)*24-d[i])/(n-i)) to x[i]

whereas d[i] is the sum of the values of x before.

Now I want to write "nequaln":=proc(k), which goes through all the values for n from 3 to k and produces a list [a_3,a_4,a_5,...,a_n].

I guess that I need to program a kind of dynamical loop, but I failed completely. May someone help me? That would be very kind.

nequal3:=proc()
local u,v,a_3;
a_3:=0;
for u from ceil((3-2)*24/(3-0)) to (3-2)*24-3+1 do
for v from ceil(((3-2)*24-u)/(3-1)) to u do
if (3-2)*24-u-v>=1 then
a_3:=a_3+1;
end if;
end do;
end do;
print(a_3);
end proc:

nequal4:=proc()
local u,v,w,a_4;
a_4:=0;
for u from ceil((4-2)*24/(4-0)) to (4-2)*24-4+1 do
for v from ceil(((4-2)*24-u)/(4-1)) to u do
for w from ceil(((4-2)*24-u-v)/(4-2)) to v do
if (4-2)*24-u-v-w>=1 then
a_4:=a_4+1;
end if;
end do;
end do;
end do;
print(a_4);
end proc:

﻿