Step back

  • Thread starter Thread starter Weng-Kit Tan
  • Start date Start date
W

Weng-Kit Tan

How do you translate this into vba code?

for i = (N-1) downto 0 do
for j = 0 to i do
C[j] = disc * ( p*C[j+1] + (1-p)*C[j] )

1.
Particularly the part about "downto", so instead of running i from 0
to (N-1), this is a step-back running from (N-1) to 0.

2.
How do you make the Function remember each individual value C[j] from
j = 0 to i
 
Hi
try
Dim N as integer
Dim i as integer
Dim j as integer
Dim C()

N=10
Redim C(N)
for i = (N-1) to 0 step -1
for j = 0 to i
C(j)=disc * ( p*C[j+1] + (1-p)*C[j] )
next j
next i


Whatever disc and p is
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top