This program automatically creates 2 local variables: 'k' and 'sum'. However, this behaviour can often lead to unexpected bugs. For example, if you mistyped one of the 'sum' variables, the program would not work as expected. No error would be given - a new variable would simply be created.
FYIScriptBasic supports something similar.
declare option DeclareVars
declare option AutoVars
You can also control if variables used in functions/subs default to local scope. By default variables created within functions are global unless they are predefined as LOCAL prior to assignment within the function.
I personally like ScriptBasic's lazy / careful programming mode as the default. If I was doing a large project in SB, I would enable these language checks during the development cycle.