ERROR: LoadError: UndefVarError: fTerm1 not defined

Hi all,

I’m new to programming with Julia, and I’m really stuck.

I keep getting an error that fTerm1 is not defined but it’s right there!
Am I being incredibly dense??

using Printf
using Statistics

fSize = 10
i1 = 1
fTerm1 = 0
fTerm2 = 1

for i1 in fSize
    nextTerm = fTerm1 + fTerm2
    fTerm1 = fTerm2
    fTerm2 = nextTerm

Any help appreciated, thanks.

1 Like

You need global to modify a global variable from a loop.

1 Like

I thought I was going nuts, thank you so much!