Necessity of Wrapping Solution into Method/Function

I've noticed that sometimes people using exotic languages like Brainfuck don't ever explicitly wrap a solution into a method/function. While sometimes I see solutions in Java and such where they are wrapping their solution into a function.

Is it actually necessary (if the question didn't specify it) to wrap a solution into a reusable function?

As an example, here is my solution to The Letter A without A:

(3<2).ToString()[3-2]


Is it necessary to make it like so?

void Solution { (3<2).ToString()[3-2] }


Which also leads me to ask is it necessary to also explicitly print the result when things like PowerShell implicitly print the result all the time, and this can be done with my C# snippet using C# Interactive for instance?