As variables are local inside while/ for loop in Julia, I was wondering how to see the changes that happen inside loop and then use the values after changes??
For example, consider a very simple implementation of raising five to the power of three:
I did try this:
x1 = 5; n1 = 3; global result = 1;
for i in range(1,n1)
result = result* x1
end
result
It will show the value of “1” for result. And once using global result = result* x1
inside for loop, it will return Multiple definitions for result.
Why is this? And how to save changes?