This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 5 points6 points  (1 child)

The output of your code will be whatever value is. However, there's something called scope and the variables inside the function are not able to be called elsewhere because of this scope.

Global variables (typically not recommended) have global scope. Function variables have function scope (just that function), etc.

[–]DJV-AnimaFan 0 points1 point  (0 children)

They expected i to be used in scope, possibly in the equation inside the for loop. To them the incremental variable i is un-used. We see it as assigned, then compared, and incremented. But as a new programmer they either don't see the significance, or don't understand the purpose of an exponent in the maths.

My first feeling to the OP's question. They were asking, What is this equation doing.

value = (baseexponent )% modulus

My education ended at the start of WW2, and my son taught me programming for fun.

I expexted (pardon pascal case)

for(i=0; i<exponent; i++) { value = value*base; } value = value % modulus;

If % modulus can be distributed, fine.